All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 49s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
763 B
TypeScript
24 lines
763 B
TypeScript
import type { Playlist } from "../model/interfaces.ts";
|
|
|
|
/** A playlist's dump, with what deciding who may see it takes. */
|
|
export interface PlaylistMember {
|
|
id: string;
|
|
isPrivate: boolean;
|
|
userId: string;
|
|
}
|
|
|
|
/**
|
|
* Whether `viewerId` sees this member when the playlist is shown to them: a
|
|
* public dump, or a private one of the owner's own, to the owner. Everyone
|
|
* else — moderators too — doesn't see private dumps, and neither does the
|
|
* owner see someone else's dump once it has gone private.
|
|
*/
|
|
export function isMemberVisibleTo(
|
|
member: PlaylistMember,
|
|
playlist: Pick<Playlist, "userId">,
|
|
viewerId: string | null | undefined,
|
|
): boolean {
|
|
return !member.isPrivate ||
|
|
(member.userId === viewerId && viewerId === playlist.userId);
|
|
}
|