ThreadApi
Swift wrapper for privmx.NativeThreadApiWrapper
, providing Thread-related operations within PrivMX platform.
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.
public func listThreads(
from contextId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.ThreadList
Name | Type | Description |
---|---|---|
contextId | String | The unique identifier of the context from which to list Threads. |
query | privmx.endpoint.core.PagingQuery | A paging query object for filtering and paginating the results. |
Type | Description |
---|---|
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.
public func getThread(
_ threadId: String
) throws -> privmx.endpoint.thread.Thread
Name | Type | Description |
---|---|---|
threadId | String | The unique identifier of the Thread to retrieve. |
Type | Description |
---|---|
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.
public func deleteThread(
_ threadId: String
) throws -> Void
Name | Type | Description |
---|---|---|
threadId | String | The 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.
public func createThread(
in contextId: String,
for users: [privmx.endpoint.core.UserWithPubKey],
managedBy managers: [privmx.endpoint.core.UserWithPubKey],
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data
) throws -> String
Name | Type | Description |
---|---|---|
contextId | String | The 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. |
publicMeta | Data | The public metadata associated with the Thread, which will not be encrypted. |
privateMeta | Data | The private metadata associated with the Thread, which will be encrypted. |
Type | Description |
---|---|
String | A `String` representing the ID of the newly created 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.
public func listMessages(
from threadId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.MessageList
Name | Type | Description |
---|---|---|
threadId | String | The unique identifier of the Thread from which to list Messages. |
query | privmx.endpoint.core.PagingQuery | A paging query object for filtering and paginating the results. |
Type | Description |
---|---|
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.
public func getMessage(
_ messageId: String
) throws -> privmx.endpoint.thread.Message
Name | Type | Description |
---|---|---|
messageId | String | The unique identifier of the Message to retrieve. |
Type | Description |
---|---|
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.
public func sendMessage(
in threadId: String,
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
containing data: Data
) throws -> String
Name | Type | Description |
---|---|---|
threadId | String | The unique identifier of the Thread to send the Message to. |
publicMeta | Data | The public metadata associated with the Message, which will not be encrypted. |
privateMeta | Data | The private metadata associated with the Message, which will be encrypted. |
data | Data | The actual content of the Message as `Data`, which will be encrypted. |
Type | Description |
---|---|
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.
public func updateMessage(
_ messageId: String,
replacingData data: Data,
replacingPublicMeta publicMeta: Data,
replacingPrivateMeta privMeta: Data
) throws -> Void
Name | Type | Description |
---|---|---|
messageId | String | The unique identifier of the Message to update. |
data | Data | The new content of the Message as `Data`, which will be encrypted. |
publicMeta | Data | The new public metadata of the Message, which will not be encrypted. |
privMeta | Data |
deleteMessage(_:)
Deletes a specific Message. This method deletes a Message identified by its unique message ID from the platform.
public func deleteMessage(
_ messageId: String
) throws -> Void
Name | Type | Description |
---|---|---|
messageId | String | The unique identifier of the Message to delete. |
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.
public func updateThread(
_ threadId: String,
atVersion version: Int64,
replacingUsers users:[privmx.endpoint.core.UserWithPubKey],
replacingManagers managers:[privmx.endpoint.core.UserWithPubKey],
replacingPublicMeta publicMeta:Data,
replacingPrivateMeta privateMeta:Data,
force: Bool,
forceGenerateNewKey: Bool
) throws -> Void
Name | Type | Description |
---|---|---|
threadId | String | The unique identifier of the Thread to update. |
version | Int64 | The 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. |
publicMeta | Data | The new public metadata of the Thread, which will not be encrypted. |
privateMeta | Data | The new private metadata of the Thread, which will be encrypted. |
force | Bool | A boolean indicating whether to force the update, bypassing version control. |
forceGenerateNewKey | Bool | A boolean indicating whether a new key should be generated for the Thread. |
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.
public func subscribeForMessageEvents(
in threadId: String
) throws -> Void
Name | Type | Description |
---|---|---|
threadId | String | The 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.
public func unsubscribeFromMessageEvents(
in threadId: String
) throws -> Void
Name | Type | Description |
---|---|---|
threadId | String | The unique identifier of the Thread for which to unsubscribe from message events. |