Reportable

protocol Reportable : Model
  • The type of report to use when reportong on this object type.

    Declaration

    Swift

    var reportType: ReportType { get }
  • The UUID of the content’s author.

    Declaration

    Swift

    var authorUUID: UUID { get }
  • How many reports on this type of content must accrue before triggering auto-quarantine.

    Declaration

    Swift

    var autoQuarantineThreshold: Int { get }
  • Things that can get reported can get moderated by the mod team. This shows the moderation status of the reportable item.

    Declaration

    Swift

    var moderationStatus: ContentModerationStatus { get set }
  • The database ID of the content. Depending on reportType, this could encode either a UUID or an Int. Don’t use this for concrete types where the actual @id type is available.

    Declaration

    Swift

    func reportableContentID() throws -> String
  • isQuarantined Extension method

    Declaration

    Swift

    var isQuarantined: Bool { get }
  • fileReport(submitter:submitterMessage:on:) Extension method, asynchronous

    Creates and saves a Report. Reports are always submitted by the parent account of any sub-account. A user may only file one report against a piece of content. If enough reports are filed against the same piece of content, this function will mark the content auto-quarantined.

    Declaration

    Swift

    func fileReport(submitter: UserCacheData, submitterMessage: String, on req: Request) async throws -> HTTPStatus
  • logIfModeratorAction(_:user:on:) Extension method, asynchronous

    If the change being made to the receiver is a mod exercising their mod powers, record the change in the ModeratorAction log. If the change isn’t the result of mod powers, do nothing. Most calls don’t need to wait for completion, and can ignore the result. Only call this function after you’re sure the action is actually going to occur.

    Declaration

    Swift

    func logIfModeratorAction(_ action: ModeratorActionType, user: UserCacheData, on req: Request) async
  • logIfModeratorAction(_:moderatorID:on:) Extension method, asynchronous

    If the change being made to the receiver is a mod exercising their mod powers, record the change in the ModeratorAction log. If the change isn’t the result of mod powers, do nothing. Most calls don’t need to wait for completion, and can ignore the result. Only call this function after you’re sure the action is actually going to occur.

    This form is best-effort: it writes through req.db and swallows write errors. Don’t use it for a change made inside a transaction; use logIfModeratorAction(_:moderatorID:on: Database) with the transaction’s database so the log entry is part of the transaction.

    Declaration

    Swift

    func logIfModeratorAction(_ action: ModeratorActionType, moderatorID: UUID, on req: Request) async throws
  • logIfModeratorAction(_:moderatorID:on:) Extension method, asynchronous

    Transaction-aware form of logIfModeratorAction(_:moderatorID:on:). Writes through db and propagates errors rather than logging them.

    This is a deliberate design choice: the moderator action log is the accountability record for mod powers, so a log entry is part of the change it records, not a side effect of it. Call this inside the same transaction as the change; the action and its log entry then succeed or fail together, and a failed log write fails the request instead of leaving a moderator action with no record. (Swallowing the error, as the Request forms do, can’t make the log best-effort here anyway: in Postgres a failed statement aborts the whole transaction, so the next statement would fail and the commit would roll back.) Don’t move this call after the commit.

    Declaration

    Swift

    func logIfModeratorAction(_ action: ModeratorActionType, moderatorID: UUID, on db: Database) async throws
  • logIfModeratorAction(_:user:on:) Extension method, asynchronous

    Transaction-aware form of logIfModeratorAction(_:user:on:). The log entry is deliberately part of the transaction; see logIfModeratorAction(_:moderatorID:on: Database).

    Declaration

    Swift

    func logIfModeratorAction(_ action: ModeratorActionType, user: UserCacheData, on db: Database) async throws

Available where IDValue == Int

Available where IDValue == UUID