UserAccessLevel

public enum UserAccessLevel : String, Codable, Sendable
extension UserAccessLevel: Comparable

All API endpoints are protected by a minimum user access level. This enum structure MUST match the values in CreateCustomEnums in SchemaCreation.swift as this enum is part of the database schema. This enum is also sent out in several Data Transfer Object types. Think very carefully about modifying these values.

  • A user account that has not yet been activated. [read-only, limited]

    Declaration

    Swift

    case unverified
  • A user account that has been banned. [cannot log in]

    Declaration

    Swift

    case banned
  • A .verified user account that has triggered Moderator review. [read-only]

    Declaration

    Swift

    case quarantined
  • A user account that has been activated for full read-write access.

    Declaration

    Swift

    case verified
  • A special class of account for registered API clients. [see ClientController]

    Declaration

    Swift

    case client
  • An account whose owner is part of the Moderator Team.

    Declaration

    Swift

    case moderator
  • Twitarr devs should have their accounts elevated to this level to help handle seamail to ‘twitarrteam’

    Declaration

    Swift

    case twitarrteam
  • tho

    An account officially associated with Management, has access to all .moderator and a subset of .admin functions (the non-destructive ones). Can ban users.

    Declaration

    Swift

    case tho
  • An Administrator account, unrestricted access.

    Declaration

    Swift

    case admin
  • Declaration

    Swift

    static func fromRawString(_ str: String) -> `Self`?
  • Declaration

    Swift

    func visibleName() -> String
  • Ensures that the access level of self grants at least the access level given in level. That is, UserAccessLevel.admin.hasAccess(.verified) returns true, while moderator.hasAccess(.admin) returns false. Although this currently uses > to test, the method could be expanded to non-hierarchy access types–and we may need to, as Clients can make calls that Moderators cannot, and vice versa.

    Declaration

    Swift

    func hasAccess(_ level: UserAccessLevel) -> Bool

Capability Queries

  • Returns TRUE iff this user is allowed to post their own content and edit or delete content they created..

    Declaration

    Swift

    func canCreateContent() -> Bool
  • Returns TRUE if this user is allowed to moderate others’ content. This includes editing text, removing images, and deleting posts. This capability does not include the ability to moderate users themselves.

    Declaration

    Swift

    func canEditOthersContent() -> Bool
  • Returns TRUE if this user can change the access level of other users. The access level of Client users cannot be changed, and only admin level users can set other users’ access level to equal their own. For example moderator users can change user levels FROM any of [unverified, banned, quarantined, verified] TO any of [unverified, banned, quarantined, verified].

    Declaration

    Swift

    func canModerateUsers() -> Bool
  • Declaration

    Swift

    public static func < (lhs: UserAccessLevel, rhs: UserAccessLevel) -> Bool