Implemented editable album title (#130)

* Replace static title text with a text edit field
* Implement endpoint for updating album info
* Implement changing title
* Only the owner can change the title
This commit is contained in:
Alex
2022-04-28 23:46:37 -05:00
committed by GitHub
parent c5c7a134dd
commit 38e0178c81
10 changed files with 290 additions and 29 deletions

View File

@@ -12,6 +12,7 @@ import { UserSharedAlbumEntity } from './entities/user-shared-album.entity';
import _ from 'lodash';
import { AddUsersDto } from './dto/add-users.dto';
import { RemoveAssetsDto } from './dto/remove-assets.dto';
import { UpdateShareAlbumDto } from './dto/update-shared-album.dto';
@Injectable()
export class SharingService {
@@ -184,4 +185,15 @@ export class SharingService {
return await this.assetSharedAlbumRepository.save([...newRecords]);
}
async updateAlbumTitle(authUser: AuthUserDto, updateShareAlbumDto: UpdateShareAlbumDto) {
if (authUser.id != updateShareAlbumDto.ownerId) {
throw new BadRequestException('Unauthorized to change album info');
}
const sharedAlbum = await this.sharedAlbumRepository.findOne({ where: { id: updateShareAlbumDto.albumId } });
sharedAlbum.albumName = updateShareAlbumDto.albumName;
return await this.sharedAlbumRepository.save(sharedAlbum);
}
}