feat(web): show partners assets on the main timeline (#4933)
This commit is contained in:
@@ -249,4 +249,15 @@ export class AccessRepository implements IAccessRepository {
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
partner = {
|
||||
hasUpdateAccess: (userId: string, partnerId: string): Promise<boolean> => {
|
||||
return this.partnerRepository.exist({
|
||||
where: {
|
||||
sharedById: partnerId,
|
||||
sharedWithId: userId,
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ export class AssetRepository implements IAssetRepository {
|
||||
}
|
||||
|
||||
private getBuilder(options: TimeBucketOptions) {
|
||||
const { isArchived, isFavorite, isTrashed, albumId, personId, userId, withStacked } = options;
|
||||
const { isArchived, isFavorite, isTrashed, albumId, personId, userIds, withStacked } = options;
|
||||
|
||||
let builder = this.repository
|
||||
.createQueryBuilder('asset')
|
||||
@@ -532,11 +532,11 @@ export class AssetRepository implements IAssetRepository {
|
||||
builder = builder.leftJoin('asset.albums', 'album').andWhere('album.id = :albumId', { albumId });
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
builder = builder.andWhere('asset.ownerId = :userId', { userId });
|
||||
if (userIds) {
|
||||
builder = builder.andWhere('asset.ownerId IN (:...userIds )', { userIds });
|
||||
}
|
||||
|
||||
if (isArchived != undefined) {
|
||||
if (isArchived !== undefined) {
|
||||
builder = builder.andWhere('asset.isArchived = :isArchived', { isArchived });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IPartnerRepository, PartnerIds } from '@app/domain';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { DeepPartial, Repository } from 'typeorm';
|
||||
import { PartnerEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
@@ -16,12 +16,22 @@ export class PartnerRepository implements IPartnerRepository {
|
||||
return this.repository.findOne({ where: { sharedById, sharedWithId } });
|
||||
}
|
||||
|
||||
async create({ sharedById, sharedWithId }: PartnerIds): Promise<PartnerEntity> {
|
||||
await this.repository.save({ sharedBy: { id: sharedById }, sharedWith: { id: sharedWithId } });
|
||||
return this.repository.findOneOrFail({ where: { sharedById, sharedWithId } });
|
||||
create({ sharedById, sharedWithId }: PartnerIds): Promise<PartnerEntity> {
|
||||
return this.save({ sharedBy: { id: sharedById }, sharedWith: { id: sharedWithId } });
|
||||
}
|
||||
|
||||
async remove(entity: PartnerEntity): Promise<void> {
|
||||
await this.repository.remove(entity);
|
||||
}
|
||||
|
||||
update(entity: Partial<PartnerEntity>): Promise<PartnerEntity> {
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
private async save(entity: DeepPartial<PartnerEntity>): Promise<PartnerEntity> {
|
||||
await this.repository.save(entity);
|
||||
return this.repository.findOneOrFail({
|
||||
where: { sharedById: entity.sharedById, sharedWithId: entity.sharedWithId },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user