PostReactionData

public struct PostReactionData : Content

Payload for adding or removing a reaction from a forum or chat post.

  • A Unicode emoji or a custom emoji token such as :arr:.

    Declaration

    Swift

    var reaction: String
  • The most distinct reactions one user may put on a single post. Enough to be expressive; small enough that one person cannot bury a post under a wall of chips.

    Declaration

    Swift

    static let maxReactionsPerUserPerPost: Int
  • The most Unicode scalars an emoji reaction may have. The longest standard emoji, such as a kiss between two people with skin tones, have 10.

    Declaration

    Swift

    static let maxReactionScalars: Int
  • Whether the value is something a reaction may be: a custom emoji token from the catalog, or exactly one emoji.

    Reactions are shown beside other people’s posts and cannot be reported like a post can, so free text is refused. “One emoji” means a single grapheme cluster of emoji scalars, plus the joiners, skin tones, presentation selectors, keycap mark and flag tags that combine them, each placed where it combines with something. A scalar that combines with nothing renders as nothing, so allowing one anywhere would let invisible padding turn one emoji into many distinct reactions that all look alike. Letters, bare digits and punctuation (which Unicode also classes as emoji, for keycaps) are not enough alone.

    Declaration

    Swift

    static func isAllowedReaction(_ value: String) -> Bool
  • An emoji in its own right, as opposed to a skin tone, selector, joiner or other scalar that only combines with one.

    Declaration

    Swift

    private static func isEmojiCharacter(_ scalar: Unicode.Scalar) -> Bool
  • Validates a small, URL-independent payload while preserving the exact submitted reaction.

    Declaration

    Swift

    func validatedReaction() throws -> String
  • Refuses a new reaction once the user already has the maximum number of distinct reactions on the post.

    Declaration

    Swift

    static func guardBelowReactionLimit(_ existingCount: Int) throws