import type { Playlist } from "../../shared/playlist.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, viewerId: string | null | undefined, ): boolean { return !member.isPrivate || (member.userId === viewerId && viewerId === playlist.userId); }