Threads
Class representing instance of Threads API
Methods
createThread
Creates a new Thread in given Context.
createThread(contextId, users, managers, publicMeta, privateMeta)
Name | Type | Description |
---|---|---|
contextId | string | ID of the Context to create the Thread in |
users | UserWithPubKey[] | array of UserWithPubKey structs which indicates who will have access to the created Thread |
managers | UserWithPubKey[] | array of UserWithPubKey structs which indicates who will have access (and management rights) to the created Thread |
publicMeta | Uint8Array | public (unencrypted) metadata |
privateMeta | Uint8Array | private (encrypted) metadata |
Type | Description |
---|---|
Promise<string> | ID of the created Thread |
updateThread
Updates an existing Thread.
updateThread(threadId, users, managers, publicMeta, privateMeta, version, force, forceGenerateNewKey)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread to update |
users | UserWithPubKey[] | array of UserWithPubKey structs which indicates who will have access to the created Thread |
managers | UserWithPubKey[] | array of UserWithPubKey structs which indicates who will have access (and management rights) to the created Thread |
publicMeta | Uint8Array | public (unencrypted) metadata |
privateMeta | Uint8Array | private (encrypted) metadata |
version | number | current version of the updated Thread |
force | boolean | force update (without checking version) |
forceGenerateNewKey | boolean | force to regenerate a key for the Thread |
deleteThread
Deletes a Thread by given Thread ID.
deleteThread(threadId)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread to delete |
getThread
Gets a Thread by given Thread ID.
getThread(threadId)
Name | Type | Description |
---|---|---|
threadId | string | ID of Thread to get |
Type | Description |
---|---|
Promise<Thread> | struct containing info about the Thread |
listThreads
Gets a list of Threads in given Context.
listThreads(contextId, pagingQuery)
Name | Type | Description |
---|---|---|
contextId | string | ID of the Context to get the Threads from |
pagingQuery | PagingQuery | struct with list query parameters |
Type | Description |
---|---|
Promise<PagingList<Thread>> | struct containing a list of Threads |
getMessage
Gets a message by given message ID.
getMessage(messageId)
Name | Type | Description |
---|---|---|
messageId | string | ID of the message to get |
Type | Description |
---|---|
Promise<Message> | struct containing the message |
listMessages
Gets a list of messages from a Thread.
listMessages(threadId, pagingQuery)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread to list messages from |
pagingQuery | PagingQuery | struct with list query parameters |
Type | Description |
---|---|
Promise<PagingList<Message>> | struct containing a list of messages |
sendMessage
Sends a message in a Thread.
sendMessage(threadId, publicMeta, privateMeta, data)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread to send message to |
publicMeta | Uint8Array | public message metadata |
privateMeta | Uint8Array | private message metadata |
data | Uint8Array | content of the message |
Type | Description |
---|---|
Promise<string> | ID of the new message |
deleteMessage
Deletes a message by given message ID.
deleteMessage(messageId)
Name | Type | Description |
---|---|---|
messageId | string | ID of the message to delete |
updateMessage
Update message in a Thread.
updateMessage(messageId, publicMeta, privateMeta, data)
Name | Type | Description |
---|---|---|
messageId | string | ID of the message to update |
publicMeta | Uint8Array | public message metadata |
privateMeta | Uint8Array | private message metadata |
data | Uint8Array | content of the message |
subscribeForThreadEvents
Subscribes for the Thread module main events.
subscribeForThreadEvents()
unsubscribeFromThreadEvents
Unsubscribes from the Thread module main events.
unsubscribeFromThreadEvents()
subscribeForMessageEvents
Subscribes for events in given Thread.
subscribeForMessageEvents(threadId)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread to subscribe |
unsubscribeFromMessageEvents
Unsubscribes from events in given Thread.
unsubscribeFromMessageEvents(threadId)
Name | Type | Description |
---|---|---|
threadId | string | ID of the Thread to unsubscribe |