ThreadViewWorld extension

The writes and reads of the thread view (brief M4-20 Scope): capabilities, main threads, operators, revisions, pins, templates, threads from a message, title, close, reopen, move and mark unread. Each write appends the event of 05 section 6 like the other writes of the world; the checks are the visibility, the level and the capability manage where 05 names it, nothing else (README).

Example:

world.grantCapability(alex.id, channel, 'manage');
world.pin(alex.id, messageId, pinned: true);
on

Methods

addMainThread(String channelId, {required String createdBy}) → String

Available on FakeWorld, provided by the ThreadViewWorld extension

Adds the main thread (kind = main) of the text channel channelId, names it in the channel's main_thread_id and returns its ID.
addTemplate({required String scope, required String name, required String contentMd, String? ownerId, String? channelId}) → JsonMap

Available on FakeWorld, provided by the ThreadViewWorld extension

Adds a template of scope (personal of ownerId, or channel of channelId) and returns it.
channelTemplates(String principalId, String channelId) → List<JsonMap>

Available on FakeWorld, provided by the ThreadViewWorld extension

listTemplates: the templates of channelId when principalId sees it.
createThreadFromMessage(String principalId, String channelId, JsonMap body) → JsonMap

Available on FakeWorld, provided by the ThreadViewWorld extension

createThread with parent_message_id: a thread from a message of the main thread of a text channel, titled from the message (title_source = auto), with an optional first message. Returns the API ThreadCreated.
grantCapability(String principalId, String channelId, String capability) → void

Available on FakeWorld, provided by the ThreadViewWorld extension

Gives principalId the capability capability (API Capability) in channelId.
markUnread(String principalId, String threadId, int lastRead, int expectedVersion, {String? deviceId}) → JsonMap

Available on FakeWorld, provided by the ThreadViewWorld extension

markThreadUnread: moves the read position of principalId in threadId back to lastRead when expectedVersion is the version of its read state (04 14), and appends read_state.updated. Throws 412 version_conflict with the current state.
moveThread(String principalId, String threadId, String targetChannelId) → JsonMap

Available on FakeWorld, provided by the ThreadViewWorld extension

moveThread: moves threadId into targetChannelId (05 thread.move: manage on source and target; the same effective operator, else 422 operator_mismatch); the ID stays and thread.moved names the source channel.
operatorOf(String threadId) → String?

Available on FakeWorld, provided by the ThreadViewWorld extension

The effective operator of the thread threadId: its own operator, else its channel's.
personalTemplates(String principalId) → List<JsonMap>

Available on FakeWorld, provided by the ThreadViewWorld extension

listMyTemplates: the personal templates of principalId.
pin(String principalId, String messageId, {required bool pinned}) → void

Available on FakeWorld, provided by the ThreadViewWorld extension

pinMessage and unpinMessage: pins or unpins messageId (05 pin.create, pin.delete: manage); a repeat changes nothing. Throws 404, 403 forbidden without manage, 410 message_deleted for a deleted message.
pinsOf(String principalId, String threadId) → List<JsonMap>

Available on FakeWorld, provided by the ThreadViewWorld extension

listPins: the pins of threadId.
revisionsOf(String principalId, String messageId) → List<JsonMap>

Available on FakeWorld, provided by the ThreadViewWorld extension

listMessageRevisions: the earlier revisions of messageId, oldest first.
setOperator(String channelId, String? agentId) → void

Available on FakeWorld, provided by the ThreadViewWorld extension

Sets the effective operator of channelId to agentId (null: no operator).
setThreadState(String principalId, String threadId, {required bool closed}) → JsonMap

Available on FakeWorld, provided by the ThreadViewWorld extension

closeThread and reopenThread of principalId (05: write); a thread already in the state changes nothing. Returns the thread.
setTitle(String principalId, String threadId, int expectedVersion, String title) → JsonMap

Available on FakeWorld, provided by the ThreadViewWorld extension

setThreadTitle: sets title with title_source = manual when expectedVersion is the thread's version, and appends thread.updated. Throws 412 version_conflict.