Chat API service. Provides methods to interact with the chat API.
Implements
- {@ember/service}
Methods
categoryPermissions(categoryId) → {Promise}
Lists chat permissions for a category.
Parameters
-
categoryId
number
ID of the category.
Returns
-
Promise
Source
channel(channelId) → {Promise}
Get a channel by its ID.
Parameters
-
channelId
number
The ID of the channel.
Returns
-
Promise
Example
this.chatApi.channel(1).then(channel => { ... })
Source
channels() → {Collection}
List all accessible category channels of the current user.
Returns
-
Collection
Example
this.chatApi.channels.then(channels => { ... })
Source
createChannel(data) → {Promise}
Creates a channel.
Parameters
-
data
object
Params of the channel.Properties
-
name
string
The name of the channel. -
chatable_id
string
The category of the channel. -
description
string
The description of the channel. -
auto_join_users
boolean
<optional>
Should users join this channel automatically.
-
name
Returns
-
Promise
Example
this.chatApi
.createChannel({ name: "foo", chatable_id: 1, description "bar" })
.then((channel) => { ... })
Source
createChannelArchive(channelId, data) → {Promise}
Creates a channel archive.
Parameters
-
channelId
number
The ID of the channel. -
data
object
Params of the archive.Properties
-
selection
string
"new_topic" or "existing_topic". -
title
string
<optional>
Title of the topic when creating a new topic. -
category_id
string
<optional>
ID of the category used when creating a new topic. -
tags
Array.<string>
<optional>
tags used when creating a new topic. -
topic_id
string
<optional>
ID of the topic when using an existing topic.
-
selection
Returns
-
Promise
Source
destroyChannel(channelId) → {Promise}
Destroys a channel.
Parameters
-
channelId
number
The ID of the channel.
Returns
-
Promise
Example
this.chatApi.destroyChannel(1).then(() => { ... })
Source
followChannel(channelId) → {Promise}
Makes current user follow a channel.
Parameters
-
channelId
number
The ID of the channel.
Returns
-
Promise
Source
listChannelMemberships(channelId) → {Collection}
Lists members of a channel.
Parameters
-
channelId
number
The ID of the channel.
Returns
-
Collection
Source
listCurrentUserChannels() → {Promise}
Lists public and direct message channels of the current user.
Returns
-
Promise
Source
moveChannelMessages(channelId, data) → {Promise}
Moves messages from one channel to another.
Parameters
-
channelId
number
The ID of the original channel. -
data
object
Params of the move.Properties
-
message_ids
Array.<number>
IDs of the moved messages. -
destination_channel_id
number
ID of the channel where the messages are moved to.
-
message_ids
Returns
-
Promise
Example
this.chatApi
.moveChannelMessages(1, {
message_ids: [2, 3],
destination_channel_id: 4,
}).then(() => { ... })
Source
sendMessage(channelId, data) → {Promise}
Sends a message.
Parameters
-
channelId
number
ID of the channel. -
data
object
Params of the message.Properties
-
message
string
The raw content of the message in markdown. -
cooked
string
The cooked content of the message. -
in_reply_to_id
number
<optional>
The ID of the replied-to message. -
staged_id
number
<optional>
The staged ID of the message before it was persisted. -
upload_ids
Array.<number>
<optional>
Array of upload ids linked to the message.
-
message
Returns
-
Promise
Source
unfollowChannel(channelId) → {Promise}
Makes current user unfollow a channel.
Parameters
-
channelId
number
The ID of the channel.
Returns
-
Promise
Source
updateChannel(channelId, data) → {Promise}
Updates a channel.
Parameters
-
channelId
number
The ID of the channel. -
data
object
Params of the archive.Properties
-
description
string
<optional>
Description of the channel. -
name
string
<optional>
Name of the channel.
-
description
Returns
-
Promise
Source
updateChannelStatus(channelId, status) → {Promise}
Updates the status of a channel.
Parameters
-
channelId
number
The ID of the channel. -
status
string
The new status, can be "open" or "closed".
Returns
-
Promise
Source
updateCurrentUserChannelNotificationsSettings(channelId, data) → {Promise}
Update notifications settings of current user for a channel.
Parameters
-
channelId
number
The ID of the channel. -
data
object
The settings to modify.Properties
-
muted
boolean
<optional>
Mutes the channel. -
desktop_notification_level
string
<optional>
Notifications level on desktop: never, mention or always. -
mobile_notification_level
string
<optional>
Notifications level on mobile: never, mention or always.
-
muted
Returns
-
Promise