PrivilegedMailbox
struct PrivilegedMailbox : Sendable
Describes one privileged shared mailbox: a non-loginable phantom User (see PrivilegedUser) that
stands in for “every real user who satisfies requirement”. A chat addressed to, or containing, the
phantom account is really addressed to every member of that roster, each of whom gets their own
Redis unread count under inbox (see MailInbox).
PrivilegedMailbox.all is the single source of truth for every “@moderator”/“@TwitarrTeam”-shaped
mailbox’s notification bookkeeping: the chat-unread fan-out, the ?foruser= access checks, and
the nightly consistency job all key off this table, so adding a new mailbox (see issue #517) means
appending a row here, adding a MailInbox case, and seeding its phantom account.
Forum @mention notifications also key off this table (forumMentionType). It does NOT cover authoring or UI: FezController.createChat‘s
createdBy… fields, PostContentData.effectiveAuthor, and SiteSeamailController’s postAs… fields are written out per mailbox
(moderator, TwitarrTeam, and CommunitySupport) and need their own updates for a new mailbox to be usable end-to-end.
-
Declaration
Swift
let user: PrivilegedUser -
Declaration
Swift
let inbox: MailInbox -
Declaration
Swift
let requirement: PrivilegedMailboxRequirement -
The notification type for a forum post that @mentions this mailbox, given the post ID and (when adding) the forum ID.
Declaration
Swift
let forumMentionType: @Sendable (Int, String?) -> NotificationType -
The
Abort(.forbidden)reason when a user withoutrequirementasks for this mailbox by name (e.g.?foruser=).Declaration
Swift
let accessDeniedReason: String -
Who may use the Community Support features: its role holders, and TwitarrTeam and above (which includes THO and admin). This is the single definition of that rule–the mailbox, the reports, the forum mentions, the badge counts and the web UI all ask it (see
UserCacheData.canAccessCommunitySupport). Route groups state the same rule toMinUserAccessLevelMiddlewareasallowedRoles+minAccess, which can’t be derived from it; keep them matching.Declaration
Swift
static let communitySupportRequirement: PrivilegedMailboxRequirement -
Order matters: a chat that somehow contains more than one phantom account resolves to the first matching mailbox here (see
forChat). This preserves existing behavior, where TwitarrTeam has always taken precedence over moderator.Declaration
Swift
static let all: [PrivilegedMailbox] -
The cached phantom account for this mailbox, or nil if the seed migration that creates it hasn’t run on this instance.
Declaration
Swift
func phantomUser(on req: Request) -> UserCacheData? -
All real users who may read this mailbox.
Declaration
Swift
func members(on req: Request) -> [UserCacheData] -
Whether
usermay read this mailbox.Declaration
Swift
func isSatisfied(by user: UserCacheData) -> Bool -
Whether a user with the given accessLevel/roles may read this mailbox. Callers that don’t have a
UserCacheData(e.g.ConsistencyJobs, which works fromUsermodels) should use this instead of reaching intorequirementdirectly.Declaration
Swift
func isSatisfied(accessLevel: UserAccessLevel, roles: Set<UserRoleType>) -> Bool -
Case-insensitive match against a
?foruser=-style query param, e.g. “moderator”/“twitarrteam”. Returns nil both for an unrecognized name and for aPrivilegedUserthat isn’t a mailbox (e.g. “admin”/“tho”, which are service accounts, not shared mailboxes).Declaration
Swift
static func matching(queryParam: String) -> PrivilegedMailbox? -
The first mailbox (in
all‘s order) whose phantom account is a member of the given chat participant list, or nil if none of the phantom accounts are present. PasssatisfiedByto additionally require that user to hold that mailbox’s access requirement–used when resolving which persona a caller may view a fez’s members-only data as; omit it to resolve the fez’s own privileged inbox regardless of who’s asking.Declaration
Swift
static func forChat(participantArray: [UUID], satisfiedBy user: UserCacheData? = nil, on req: Request) -> PrivilegedMailbox?
View on GitHub