Decides which of a playlist's dumps a viewer may see. The playlist service filters its listings with it, the WebSocket service filters each client's playlist_dumps_updated message the same way, and the queries that list playlists count their dumps by the same rule.

Functions

f
dumpFiguresFor(
members: DatedPlaylistMember[],
playlist: Pick<Playlist, "userId">,
viewerId: string | null | undefined
):
Required<Pick<Playlist, "dumpCount">>
& Pick<Playlist, "lastDumpAt">

Returns what playlist says of its dumps to the viewer, members being all of them: the dumpCount and lastDumpAt that VISIBLE_DUMP_FIGURES reads in a query. The WebSocket service puts them on the playlist each socket is sent.

f
isMemberVisibleTo(
member: PlaylistMember,
playlist: Pick<Playlist, "userId">,
viewerId: string | null | undefined
): boolean

Checks whether viewerId may see member in playlist. A public dump is visible to all. A private dump is visible only to the playlist's owner, and only if they posted it: moderators don't see it, and neither does the owner once someone else's dump in their playlist goes private. A null or undefined viewerId is a signed-out viewer.

Interfaces

I
DatedPlaylistMember

The fields of a playlist's dump that dumpFiguresFor needs: those that tell who may see it, and when it was added. The playlist service reads them for its broadcasts.

I
PlaylistMember

The fields of a playlist's dump that isMemberVisibleTo needs. A Dump has them. For its broadcasts, the playlist service reads only these.

Variables

v
VISIBLE_DUMP_FIGURES: string

The dump_count and last_dump_at columns of a query on playlists p: how many of the playlist's dumps the viewer may see, by isMemberVisibleTo's rule, and when the latest of them was added, null without any. Both read the viewer's id, or "" for a signed-out one, as ?1: it is the query's first parameter, and each ? after it takes the next.