Constructor
new Client(el, auth, optionsopt)
Example
const client = new forsta.messenger.Client(document.querySelector('#myDivId'),
{orgEphemeralToken: 'secret'});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
el |
Element | Element where the messenger should be loaded. https://developer.mozilla.org/en-US/docs/Web/API/Element |
|
auth |
ClientAuth | Auth configuration for Forsta user account. |
|
options |
ClientOptions |
<optional> |
Fires:
Methods
addEventListener(event, callback)
Add an event listener.
Parameters:
Name | Type | Description |
---|---|---|
event |
string | Name of the event to listen to. |
callback |
function | Callback function to invoke. |
(async) navPanelToggle(collapseopt)
Expand or collapse the navigation panel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
collapse |
bool |
<optional> |
Force the desired collapse state. |
removeEventListener(event, callback)
Remove an event listener.
Parameters:
Name | Type | Description |
---|---|---|
event |
string | Name of the event to stop listening to. |
callback |
function | Callback function used with |
(async) threadAddMember(id, userId) → {TagExpression}
Add a user ID to a thread's distribution.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to alter. |
userId |
UserID | User ID to add to the thread's distribution. |
Returns:
- The updated tag expression.
- Type
- TagExpression
(async) threadAmendDistribution(id, expression) → {TagExpression}
Amend the distribution of a thread by adding tag expressions to it.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to alter. |
expression |
TagExpression | Snip of valid tag expression to add to the thread. |
Returns:
- The updated tag expression.
- Type
- TagExpression
(async) threadArchive(id)
Archive a thread.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to archive. |
(async) threadDestroyMessages(id)
Delete local copy of messages for a thread.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to delete messages from. |
(async) threadEnsure(expression, attrsopt) → {string}
Ensure that a thread exists matching the expression argument.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
expression |
TagExpression | The thread distribution to match on or create. |
|
attrs |
ThreadAttributes |
<optional> |
Optional attributes to be applied to the resulting thread. |
Returns:
The thread ID created or matching the expression provided.
- Type
- string
(async) threadExpunge(id)
Expunging a thread deletes it and all its messages forever.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to expunge. |
(async) threadGetAttribute(id, attr) → {*}
Get the value of a thread attribute.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to update. |
attr |
string | The thread attribute to get. |
Returns:
- The value of the thread attribute.
- Type
- *
(async) threadLeave(id)
Leave a thread. I.e. remove yourself from a thread's distribution.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to alter. |
(async) threadList() → {Array.<string>}
List threads known to this client.
Returns:
- List of thread IDs.
- Type
- Array.<string>
(async) threadListAttributes(id) → {Array.<string>}
List the attributes of a thread.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to update. |
Returns:
- List of thread attibutes.
- Type
- Array.<string>
(async) threadMake(expression, attrsopt) → {string}
Make a new thread.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
expression |
TagExpression | The thread distribution to create. |
|
attrs |
ThreadAttributes |
<optional> |
Optional attributes to be applied to the resulting thread. |
Returns:
The thread ID created or matching the expression provided.
- Type
- string
(async) threadOpen(id)
Open a thread by its ID
.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The thread ID to open. |
(async) threadRemoveMember(id, userId) → {TagExpression}
Remove a user ID from a thread's distribution.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to alter. |
userId |
UserID | User ID to remove from the thread's distribution. |
Returns:
- The updated tag expression.
- Type
- TagExpression
(async) threadRepealDistribution(id, expression) → {TagExpression}
Repeal a subset of a thread's distribution.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to alter. |
expression |
TagExpression | Snip of valid tag expression to repeal from the thread. |
Returns:
- The updated tag expression.
- Type
- TagExpression
(async) threadRestore(id)
Restore an archived thread to normal status.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to restore from the archives. |
(async) threadSendControl(id, data, attachmentsopt, optionsopt) → {string}
Send a control message to a thread.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
ThreadID | The thread ID to send a message to. |
|
data |
Object | Object containing the control information. Read |
|
attachments |
Array |
<optional> |
Array of attachment objects. |
options |
Object |
<optional> |
Send options. |
Returns:
- The ID of the message sent.
- Type
- string
(async) threadSendMessage(id, plainText, htmlopt, attachmentsopt, attrsopt, optionsopt) → {string}
Send a message to a thread.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
ThreadID | The thread ID to send a message to. |
|
plainText |
string | Plain text message to send. |
|
html |
string |
<optional> |
HTML version of message to send. |
attachments |
Array |
<optional> |
Array of attachment objects. |
attrs |
Object |
<optional> |
Message attributes. |
options |
Object |
<optional> |
Send options. |
Returns:
- The ID of the message sent.
- Type
- string
(async) threadSendUpdate(id, updates, optionsopt)
Send a thread update to members of a thread.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
ThreadID | The thread ID to send a message to. |
|
updates |
Object | Object containing the update key/value pairs. See the |
|
options |
Object |
<optional> |
Options for the thread update. |
(async) threadSetAttribute(id, attr, value)
Set the value of a thread attribute.
Parameters:
Name | Type | Description |
---|---|---|
id |
ThreadID | The thread ID to update. |
attr |
string | The thread attribute to update. |
value |
* | The value to set. |
(async) threadSetExpiration(id, expiration)
Set the expiration time for messages in a thread. When this value is set to a non-zero
value, messages will expire from the thread after they are read. Set this value to 0
to disable the expiration behavior.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The thread ID to update. |
expiration |
number | Expiration time in seconds. The expiration timer starts when the message is read by the recipient. |
(async) threadStartWithExpression(expression, attrsopt) → {string}
Select or create a thread. If the tag expression
argument matches an
existing thread it will be opened, otherwise a new thread will be created.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
expression |
TagExpression | The thread distribution to match on or create. |
|
attrs |
ThreadAttributes |
<optional> |
Optional attributes to be applied to the resulting thread. |
Returns:
The thread ID that was opened or created.
- Type
- string