Skip to content

Commit

Permalink
fix see asset E-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
pontussjostedt committed Feb 18, 2025
1 parent 49c362e commit a823d8d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/src/interfaces/asset.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface AssetBuilderOptions {
isFavorite?: boolean;
isTrashed?: boolean;
isDuplicate?: boolean;
isEAdmin?: boolean;
albumId?: string;
tagId?: string;
personId?: string;
Expand Down
2 changes: 1 addition & 1 deletion server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ export class AssetRepository implements IAssetRepository {
builder.leftJoin('asset.albums', 'album').andWhere('album.id = :albumId', { albumId: options.albumId });
}

if (options.userIds) {
if (options.userIds && !options.isEAdmin) {
builder.andWhere('asset.ownerId IN (:...userIds )', { userIds: options.userIds });
}

Expand Down
8 changes: 5 additions & 3 deletions server/src/services/timeline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export class TimelineService extends BaseService {
dto: TimeBucketAssetDto,
): Promise<AssetResponseDto[] | SanitizedAssetResponseDto[]> {
await this.timeBucketChecks(auth, dto);
const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto);
const timeBucketOptions = await this.buildTimeBucketOptions(auth, dto, true);
const assets = await this.assetRepository.getTimeBucket(dto.timeBucket, timeBucketOptions);
return !auth.sharedLink || auth.sharedLink?.showExif
? assets.map((asset) => mapAsset(asset, { withStack: true, auth }))
: assets.map((asset) => mapAsset(asset, { stripMetadata: true, auth }));
}

private async buildTimeBucketOptions(auth: AuthDto, dto: TimeBucketDto): Promise<TimeBucketOptions> {
private async buildTimeBucketOptions(auth: AuthDto, dto: TimeBucketDto, allowEAdminBypass: boolean = false): Promise<TimeBucketOptions> {
const { userId, ...options } = dto;
let userIds: string[] | undefined = undefined;

Expand All @@ -42,7 +42,9 @@ export class TimelineService extends BaseService {
}
}

return { ...options, userIds };
const isEAdmin = allowEAdminBypass && (auth.features.includes('superadmin') || auth.features.includes('emmech_admin') || auth.user.isAdmin)

return { ...options, userIds, isEAdmin };
}

private async timeBucketChecks(auth: AuthDto, dto: TimeBucketDto) {
Expand Down

0 comments on commit a823d8d

Please sign in to comment.