mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): partner ids (#10321)
This commit is contained in:
parent
c896fe393f
commit
78f600ebce
6 changed files with 57 additions and 35 deletions
|
|
@ -2,6 +2,7 @@ import { AccessCore, Permission } from 'src/cores/access.core';
|
|||
import { BulkIdErrorReason, BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { IAccessRepository } from 'src/interfaces/access.interface';
|
||||
import { IPartnerRepository } from 'src/interfaces/partner.interface';
|
||||
import { setDifference, setUnion } from 'src/utils/set';
|
||||
|
||||
export interface IBulkAsset {
|
||||
|
|
@ -91,3 +92,33 @@ export const removeAssets = async (
|
|||
|
||||
return results;
|
||||
};
|
||||
|
||||
export type PartnerIdOptions = {
|
||||
userId: string;
|
||||
repository: IPartnerRepository;
|
||||
/** only include partners with `inTimeline: true` */
|
||||
timelineEnabled?: boolean;
|
||||
};
|
||||
export const getMyPartnerIds = async ({ userId, repository, timelineEnabled }: PartnerIdOptions) => {
|
||||
const partnerIds = new Set<string>();
|
||||
const partners = await repository.getAll(userId);
|
||||
for (const partner of partners) {
|
||||
// ignore deleted users
|
||||
if (!partner.sharedBy || !partner.sharedWith) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// wrong direction
|
||||
if (partner.sharedWithId !== userId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (timelineEnabled && !partner.inTimeline) {
|
||||
continue;
|
||||
}
|
||||
|
||||
partnerIds.add(partner.sharedById);
|
||||
}
|
||||
|
||||
return [...partnerIds];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue