Skip to main content
reference

PrivMXThread

Declaring thread and message management methods using Swift types.

Methods

listThreads(from:basedOn:)

Lists the Threads the user has access to in a specified context. This method retrieves a list of Threads in the given context, with pagination and filtering options.

func listThreads(
from contextId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.ThreadList

NameTypeDescription
contextIdStringThe unique identifier of the context from which to list Threads.
queryprivmx.endpoint.core.PagingQueryA paging query object for filtering and paginating the results.

TypeDescription
privmx.ThreadList A `privmx.endpoint.thread.ThreadsList` instance containing the list of Threads.

getThread(_:)

Retrieves detailed information about a specific Thread. This method returns metadata and details of a Thread identified by its unique thread ID.

func getThread(
_ threadId: String
) throws -> privmx.endpoint.thread.Thread

NameTypeDescription
threadIdStringThe unique identifier of the Thread to retrieve.

TypeDescription
privmx.endpoint.thread.Thread A `privmx.endpoint.thread.Thread` instance containing the Thread’s details.

deleteThread(_:)

Deletes a specific Thread from the platform. This method removes a Thread, identified by its thread ID, from the platform.

func deleteThread(
_ threadId: String
) throws -> Void

NameTypeDescription
threadIdStringThe unique identifier of the Thread to delete.

createThread(in:for:managedBy:withPublicMeta:withPrivateMeta:)

Creates a new Thread in a specified context. This method creates a new Thread with specified users, managers, and metadata in the given context. Note: Managers do not automatically have access to the thread unless explicitly added as users.

func createThread(
in contextId: String,
for users: [privmx.endpoint.core.UserWithPubKey],
managedBy managers: [privmx.endpoint.core.UserWithPubKey],
withPublicMeta pubMeta: Data,
withPrivateMeta privMeta: Data
) throws -> String

NameTypeDescription
contextIdStringThe unique identifier of the context in which to create the Thread.
users[privmx.endpoint.core.UserWithPubKey]A list of `UserWithPubKey` objects representing users who will have access to the Thread.
managers[privmx.endpoint.core.UserWithPubKey]A list of `UserWithPubKey` objects representing managers responsible for the Thread.
pubMetaData
privMetaData

TypeDescription
String A `String` representing the ID of the newly created Thread.

updateThread(_:atVersion:replacingUsers:replacingManagers:replacingPublicMeta:replacingPrivateMeta:force:forceGenerateNewKey:)

Updates an existing Thread with new users, managers, and metadata. This method updates a Thread, replacing its existing users, managers, and metadata with new values. The update can be forced and a new key can be generated if necessary.

func updateThread(
_ threadId: String,
atVersion version: Int64,
replacingUsers users: [privmx.endpoint.core.UserWithPubKey],
replacingManagers managers: [privmx.endpoint.core.UserWithPubKey],
replacingPublicMeta pubMeta: Data,
replacingPrivateMeta privMeta: Data,
force: Bool,
forceGenerateNewKey: Bool
) throws -> Void

NameTypeDescription
threadIdStringThe unique identifier of the Thread to update.
versionInt64The current version of the Thread, used to ensure version consistency.
users[privmx.endpoint.core.UserWithPubKey]A new list of `UserWithPubKey` objects representing users who will have access to the Thread.
managers[privmx.endpoint.core.UserWithPubKey]A new list of `UserWithPubKey` objects representing managers responsible for the Thread.
pubMetaData
privMetaData
forceBoolA boolean indicating whether to force the update, bypassing version control.
forceGenerateNewKeyBoolA boolean indicating whether a new key should be generated for the Thread.

listMessages(from:basedOn:)

Lists Messages from a specific Thread. This method retrieves a list of Messages from the specified Thread, filtered and paginated based on the query.

func listMessages(
from threadId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.MessageList

NameTypeDescription
threadIdStringThe unique identifier of the Thread from which to list Messages.
queryprivmx.endpoint.core.PagingQueryA paging query object for filtering and paginating the results.

TypeDescription
privmx.MessageList A `privmx.endpoint.core.MessageList` instance containing the list of Messages.

getMessage(_:)

Retrieves a specific Message by its ID. This method returns the details of a Message identified by its message ID.

func getMessage(
_ messageId: String
) throws -> privmx.endpoint.thread.Message

NameTypeDescription
messageIdStringThe unique identifier of the Message to retrieve.

TypeDescription
privmx.endpoint.thread.Message A `privmx.endpoint.thread.Message` instance containing the Message’s details.

sendMessage(in:withPublicMeta:withPrivateMeta:containing:)

Sends a Message in a Thread. This method sends a Message to the specified Thread, with the option to include both public and private metadata.

func sendMessage(
in threadId: String,
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
containing data: Data
) throws -> String

NameTypeDescription
threadIdStringThe unique identifier of the Thread to send the Message to.
publicMetaDataThe public metadata associated with the Message, which will not be encrypted.
privateMetaDataThe private metadata associated with the Message, which will be encrypted.
dataDataThe actual content of the Message as `Data`, which will be encrypted.

TypeDescription
String A `String` representing the ID of the created Message.

updateMessage(_:replacingData:replacingPublicMeta:replacingPrivateMeta:)

Updates an existing Message. This method updates a Message by replacing its data and metadata with new values.

func updateMessage(
_ messageId: String,
replacingData data: Data,
replacingPublicMeta publicMeta: Data,
replacingPrivateMeta privMeta: Data
) throws -> Void

NameTypeDescription
messageIdStringThe unique identifier of the Message to update.
dataDataThe new content of the Message as `Data`, which will be encrypted.
publicMetaDataThe new public metadata of the Message, which will not be encrypted.
privMetaData

deleteMessage(_:)

Deletes a specific Message. This method deletes a Message identified by its unique message ID from the platform.

func deleteMessage(
_ messageId: String
) throws -> Void

NameTypeDescription
messageIdStringThe unique identifier of the Message to delete.

subscribeForThreadEvents()

func subscribeForThreadEvents(
) throws -> Void

unsubscribeFromThreadEvents()

func unsubscribeFromThreadEvents(
) throws -> Void

subscribeForMessageEvents(in:)

Subscribes to receive events related to Messages in a specific Thread. This method subscribes to message-related events, allowing the client to receive notifications about changes in the Messages of the specified Thread.

func subscribeForMessageEvents(
in threadId: String
) throws -> Void

NameTypeDescription
threadIdStringThe unique identifier of the Thread for which to subscribe to message events.

unsubscribeFromMessageEvents(in:)

Unsubscribes from receiving events related to Messages in a specific Thread. This method unsubscribes from message-related events for the specified Thread, stopping further notifications.

func unsubscribeFromMessageEvents(
in threadId: String
) throws -> Void

NameTypeDescription
threadIdStringThe unique identifier of the Thread for which to unsubscribe from message events.