PostReactionBuilder

enum PostReactionBuilder

Builds each post’s grouped reactions together with the reaction revision they belong to.

  • Declaration

    Swift

    struct Snapshot
  • Builds forum snapshots without the reactions of hiddenUsers (usually the viewer’s blocks), optionally on the caller’s transaction.

    Declaration

    Swift

    static func forum(postIDs: [Int], hiding hiddenUsers: Set<UUID>, on req: Request, db: Database? = nil) async throws
    	-> [Int: Snapshot]
  • Builds chat snapshots without the reactions of hiddenUsers (usually the viewer’s blocks), optionally on the caller’s transaction.

    Declaration

    Swift

    static func fez(postIDs: [Int], hiding hiddenUsers: Set<UUID>, on req: Request, db: Database? = nil) async throws
    	-> [Int: Snapshot]
  • Reads each post’s revision. Callers read the reactions afterwards, so outside a transaction a snapshot can pair a revision with newer reactions but never with older ones; a client that discards lower revisions still ends up showing the newest reactions.

    Declaration

    Swift

    private static func revisions<Post: Model>(of _: Post.Type, postIDs: [Int], on db: Database) async throws
    	-> [Int: Int]
  • Declaration

    Swift

    private struct RevisionRow : Decodable
  • Groups reactions by post and emoji. Reactions arrive in chip order, so each chip appears where its first reaction does.

    Declaration

    Swift

    private static func snapshots(revisions: [Int: Int], reactions: [(postID: Int, emoji: String, userID: UUID)],
    	on req: Request) -> [Int: Snapshot]