feat(web): show partners assets on the main timeline (#4933)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryColumn, UpdateDateColumn } from 'typeorm';
|
||||
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryColumn, UpdateDateColumn } from 'typeorm';
|
||||
|
||||
import { UserEntity } from './user.entity';
|
||||
|
||||
@@ -23,4 +23,7 @@ export class PartnerEntity {
|
||||
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt!: Date;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
inTimeline!: boolean;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AdddInTimelineToPartnersTable1699562570201 implements MigrationInterface {
|
||||
name = 'AdddInTimelineToPartnersTable1699562570201'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "partners" ADD "inTimeline" boolean NOT NULL DEFAULT false`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "partners" DROP COLUMN "inTimeline"`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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