Skip to main content

Module moderation

Module moderation 

Source
Expand description

Contract moderation: the declaration, inside a data contract’s config, that the contract keeps a banlist, a suspension list and/or a warning list of identities, and who may edit them.

An identity on the banlist, or on the suspension list with a suspension that has not lapsed, cannot act on the contract at the document level: every document transition it signs against the contract is refused. Token transitions are not affected. A warning bars nothing: it is a record, with a reason and a time, that the identity and everyone else can read, and that accumulates until a moderator clears it. The lists live under the contract’s own subtree in Drive (keys 128, 192 and 224 of its other tree, [64, id, 2]) and are edited by the ContractUserModeration state transition.

The same moderators may delete the documents of the document types that say so (moderatorAbilities.delete), and write the fields a document type keeps for them (moderatorAbilities.changeFields), with the same transition. Each removal leaves a ContractDocumentRemoval under the contract (key 16 of its other tree).

A contract may instead declare that its moderators are an elected team: until one is seated, the interim moderators the declaration names moderate as the merged kinds do, or nobody does and the moderated document types wait.

Re-exports§

pub use elected::ElectedModerators;
pub use elected::InterimModerators;
pub use elected::ModerationAbility;
pub use elected::DEFAULT_ELECTION_WINDOW_SECONDS;

Modules§

elected
Elected moderation: the declaration that a contract’s moderators are a team chosen by masternodes and evonodes instead of by the contract owner (protocol version 14).

Structs§

ContractBan
A banlist entry.
ContractDocumentRemoval
The record a contract keeps of a document one of its moderators deleted.
ContractDocumentRestoration
The mark a restore leaves on a removal record: who brought the document back, and when.
ContractModerationConfig
The moderation a data contract declares in its config.
ContractModerationDocument
A document a moderation reason is about, named by its document type and its id.
ContractModerationListStatuses
One identity’s status on the lists that were read, one entry per list, in the order read: what a status query answers for the lists it names, and what the proof of a moderation transition’s execution shows. A list the query did not name is absent, not empty: an identity that is not suspended may still be banned when the banlist was not read. Query every list the contract keeps for the whole picture.
ContractModerationReason
Why a moderator banned, suspended or warned an identity, or deleted a document. Every such action carries one, and it is stored with the entry or the record, so whoever reads the list reads the reason.
ContractModerationStatus
What a contract’s moderation lists say about one identity.
ContractSuspension
A suspension list entry.
ContractTeamAction
A proposal the seated moderation team of an elected contract votes on, kept under the contract (protocol version 14): the team’s counterpart of a token group action.
ContractWarning
One warning of a warning list entry.
SettledDeletionRule
Who must approve a moderator’s deletion of a settled document: one past the window its document type gives its moderators (moderatorAbilities.deleteWithin). The document type’s moderatorAbilities.deleteSettled (protocol version 14), on a contract whose moderators are an elected team: so many members of the seated team, the leader counted among them when it approves, and the leader among them only when leader is set; with leader unset, any members meet it. While approvers_predate_document is set, a member the leader added counts only for documents created after its addition.

Enums§

ContractModerationList
Which of the moderation lists an action or a query refers to.
ContractModerationListStatus
What one of a contract’s moderation lists says about one identity, and nothing about the other list. It is what the proof of a moderation transition’s execution shows: that proof holds the edited entry only, so the other list stays unknown rather than being reported as empty (an identity unsuspended a moment ago may well be banned).
ContractModerators
Who may send a ContractUserModeration transition for the contract.
ContractTeamActionEvent
What a ContractTeamAction does once approved.

Functions§

decode_kept_fields
Reads the values encode_kept_fields wrote, under document_type: each kept path to its value, typed as reading the document gives it, a path the document held no value at left out. Refuses bytes that end before the last path or run past it.
document_schema_grants_moderator_abilities
Whether a raw document type schema gives the contract’s moderators an ability over its documents: deleting them, or changing their moderator fields.
document_schema_lets_moderators_change_fields
Whether a raw document type schema lists fields only the contract’s moderators write (a non-empty moderatorAbilities.changeFields).
document_schema_lets_moderators_delete
Whether a raw document type schema lets the contract’s moderators delete its documents (moderatorAbilities.delete: true).
document_schema_lets_moderators_delete_settled
Whether a raw document type schema lets the members of a seated moderation team delete its documents once settled, past deleteWithin (a moderatorAbilities.deleteSettled object).
encode_kept_fields
Encodes the values a removal record keeps of document, a document of document_type (moderatorAbilities.deleteKeepsFields), the way the document encodes its properties: for each path the type lists, in the list’s order, 0 when the document holds no value there, or 1 followed by the value as an optional property of its type is written (DocumentPropertyType::encode_value_ref_with_size), an object length-prefixed with its members in order, a time or a block height as eight big-endian bytes and a core block height as four. The paths themselves are not written: the type lists them and never changes the list, so a reader knows them from the type. Empty for a type that keeps none.
kept_value_at
What a removal record says of property, from the paths its document type keeps (kept_paths, its moderatorAbilities.deleteKeepsFields) and the values the record keeps (kept_values, ContractDocumentRemoval::kept_values): None when the record does not keep it, neither kept itself nor inside a kept object; otherwise the value, Some(None) when the document held none there. Kept paths never nest, so at most one covers it.