ThreadApi
Manages Threads and messages.
Constructors
ThreadApi
Initialize Thread module on given active connection.
public void ThreadApi(
Connection connection
)
Name | Type | Description |
---|---|---|
connection | Connection | active connection to PrivMX Bridge |
Methods
close
Frees memory.
public void close()
createThread
Creates a new Thread in given Context.
public String createThread(
String contextId,
List<UserWithPubKey> users,
List<UserWithPubKey> managers,
byte[] publicMeta,
byte[] privateMeta
)
Name | Type | Description |
---|---|---|
contextId | String | ID of the Context to create the Thread in |
users | List<UserWithPubKey> | list of UserWithPubKey which indicates who will have access to the created Thread |
managers | List<UserWithPubKey> | list of UserWithPubKey which indicates who will have access (and management rights) to the created Thread |
publicMeta | byte[] | public (unencrypted) metadata |
privateMeta | byte[] | private (encrypted) metadata |
Type | Description |
---|---|
String | ID of the created Thread |
deleteMessage
Deletes a message by given message ID.
public void deleteMessage(
String messageId
)
Name | Type | Description |
---|---|---|
messageId | String | ID of the message to delete |
deleteThread
Deletes a Thread by given Thread ID.
public void deleteThread(
String threadId
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to delete |
getMessage
Gets a message by given message ID.
public Message getMessage(
String messageId
)
Name | Type | Description |
---|---|---|
messageId | String | ID of the message to get |
Type | Description |
---|---|
Message | Message with matching id |
getThread
Gets a Thread by given Thread ID.
public Thread getThread(
String threadId
)
Name | Type | Description |
---|---|---|
threadId | String | ID of Thread to get |
Type | Description |
---|---|
Thread | Information about the Thread |
listMessages
Gets a list of messages from a Thread.
public PagingList<Message> listMessages(
String threadId,
long skip,
long limit,
String sortOrder
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to list messages from |
skip | long | skip number of elements to skip from result |
limit | long | limit of elements to return for query |
sortOrder | String | order of elements in result ("asc" for ascending, "desc" for descending) |
Type | Description |
---|---|
PagingList<Message> | list of messages |
listMessages
Gets a list of messages from a Thread.
public PagingList<Message> listMessages(
String threadId,
long skip,
long limit,
String sortOrder,
String lastId
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to list messages from |
skip | long | skip number of elements to skip from result |
limit | long | limit of elements to return for query |
sortOrder | String | order of elements in result ("asc" for ascending, "desc" for descending) |
lastId | String | ID of the element from which query results should start |
Type | Description |
---|---|
PagingList<Message> | list of messages |
listThreads
Gets a list of Threads in given Context.
public PagingList<Thread> listThreads(
String contextId,
long skip,
long limit,
String sortOrder
)
Name | Type | Description |
---|---|---|
contextId | String | ID of the Context to get the Threads from |
skip | long | skip number of elements to skip from result |
limit | long | limit of elements to return for query |
sortOrder | String | order of elements in result ("asc" for ascending, "desc" for descending) |
Type | Description |
---|---|
PagingList<Thread> | list of Threads |
listThreads
Gets a list of Threads in given Context.
public PagingList<Thread> listThreads(
String contextId,
long skip,
long limit,
String sortOrder,
String lastId
)
Name | Type | Description |
---|---|---|
contextId | String | ID of the Context to get the Threads from |
skip | long | skip number of elements to skip from result |
limit | long | limit of elements to return for query |
sortOrder | String | order of elements in result ("asc" for ascending, "desc" for descending) |
lastId | String | ID of the element from which query results should start |
Type | Description |
---|---|
PagingList<Thread> | list of Threads |
sendMessage
Sends a message in a Thread.
public String sendMessage(
String threadId,
byte[] publicMeta,
byte[] privateMeta,
byte[] data
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to send message to |
publicMeta | byte[] | public message metadata |
privateMeta | byte[] | private message metadata |
data | byte[] | content of the message |
Type | Description |
---|---|
String | ID of the new message |
subscribeForMessageEvents
Subscribes for events in given Thread.
public void subscribeForMessageEvents(
String threadId
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to subscribe |
subscribeForThreadEvents
Subscribes for the Thread module main events.
public void subscribeForThreadEvents()
unsubscribeFromMessageEvents
Unsubscribes from events in given Thread.
public void unsubscribeFromMessageEvents(
String threadId
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to unsubscribe |
unsubscribeFromThreadEvents
Unsubscribes from the Thread module main events.
public void unsubscribeFromThreadEvents()
updateMessage
Updates message in a Thread.
public void updateMessage(
String messageId,
byte[] publicMeta,
byte[] privateMeta,
byte[] data
)
Name | Type | Description |
---|---|---|
messageId | String | ID of the message to update |
publicMeta | byte[] | public message metadata |
privateMeta | byte[] | private message metadata |
data | byte[] | new content of the message |
updateThread
Updates an existing Thread.
public void updateThread(
String threadId,
List<UserWithPubKey> users,
List<UserWithPubKey> managers,
byte[] publicMeta,
byte[] privateMeta,
long version,
boolean force
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to update |
users | List<UserWithPubKey> | list of UserWithPubKey which indicates who will have access to the updated Thread |
managers | List<UserWithPubKey> | list of UserWithPubKey which indicates who will have access (and management rights) to the updated Thread |
publicMeta | byte[] | public (unencrypted) metadata |
privateMeta | byte[] | private (encrypted) metadata |
version | long | current version of the updated Thread |
force | boolean | force update (without checking version) |
updateThread
Updates an existing Thread.
public void updateThread(
String threadId,
List<UserWithPubKey> users,
List<UserWithPubKey> managers,
byte[] publicMeta,
byte[] privateMeta,
long version,
boolean force,
boolean forceGenerateNewKey
)
Name | Type | Description |
---|---|---|
threadId | String | ID of the Thread to update |
users | List<UserWithPubKey> | list of UserWithPubKey which indicates who will have access to the updated Thread |
managers | List<UserWithPubKey> | list of UserWithPubKey which indicates who will have access (and management rights) to the updated Thread |
publicMeta | byte[] | public (unencrypted) metadata |
privateMeta | byte[] | private (encrypted) metadata |
version | long | current version of the updated Thread |
force | boolean | force update (without checking version) |
forceGenerateNewKey | boolean | force to regenerate a key for the Thread |