Database structure
https://excalidraw.com/#json=6583019510956032,3U8twxl8OgyBScD1yXFTXQ
New additions are colored green.
Table | Column | Definition |
---|---|---|
Channels | TotalMsgCountRoot | Total number of root messages |
ChannelMembers | MsgCountRoot | Number of seen root messages |
MentionCountRoot | Number of unread mentions in root messages | |
Threads | PostId | Id of the root post |
ChannelId | ||
ReplyCount | Number or reply posts in this thread | |
LastReplyAt | Timestamp of the last reply | |
Participants | json array of all thread member IDs | |
ThreadMemberships | PostId | Id of the root post |
UserId | Id of the user | |
Following | Is the thread followed | |
UnreadMentions | Number of unread mentions for this user in the thread | |
LastViewed | Timestamp of when the thread was last viewed | |
LastUpdated | Timestamp of the last change to the thread (follow state, mentions, etc) |
API
New APIs
Path | Method | Description |
---|---|---|
api/v4/users/{user_id}/teams/{team_id}/threads | GET | Return threads that the user is following |
api/v4/users/{user_id}/teams/{team_id}/threads/read | PUT | Mark all threads as read |
api/v4/users/{user_id}/teams/{team_id}/{thread_id} | GET | Get one thread by Id |
api/v4/users/{user_id}/teams/{team_id}/{thread_id}/following | PUT | Start following a thread |
api/v4/users/{user_id}/teams/{team_id}/{thread_id}/following | DELETE | Stop following a thread |
api/v4/users/{user_id}/teams/{team_id}/{thread_id}/read/{timestamp} | PUT | Change ‘read’ state of a thread based on the timestamp |
Updated APIs
All ‘get posts’ methods, i.e.:/api/v4/users/{user_id}/channels/{channel_id}/posts/unread
/api/v4/channels/{channel_id}/posts
/api/v4/posts/{post_id}/thread
Will receive additional optional query parameter: collapsedThreads=true
Optionally, extendedCollapsedThreads=true
can be provided to enrich participants
array
In this mode, the output of these API calls will change, instead of returning all posts, only top-level posts will be returned, and for those posts that have replies (i.e. threads), additional fields will be added to the output:
participants
- array of user IDs (used to show avatars under the thread info in the channel):[{id:"zxxxx", id:"xcccvbs"}]
or ifextendedCollapsedThreads
is set it will return the full user objectsreply_count
- amount of repliesfollowed
- if current user is following this threadlast_reply_at
- timestamp of last replyunreadReplies
- unread replies in this threadunreadMentions
- unread mentions in this thread
Config
ServiceSettings.CollapsedThreads
Defaults to ‘disabled’.
Can also be ‘default_on’ or ‘default_off’ to set thread preference for users.
User can override via user preference: ‘collapsed_threads_settings.collapsed_threads_enabled’
ServiceSettings.ThreadAutoFollow
Defaults to ‘true’.
Controls if the threads are autofollowed when:
Somebody replies to your post
You are mentioned in a thread
When someone replies to a root post you are mentioned in
Websocket events
New events
thread_updated
issued when there is a change in a thread (new post). includes thread details in ‘thread’ field.
thread_follow_changed
issued when a thread ‘followed’ state is changed
includes ‘thread_id’ and ‘state’ fields, ‘state’ is true/false indicating following/unfollowed
thread_read_changed
issued when a thread ‘read’ state is changed
includes ‘thread_id’ and ‘timestamp’ fields, ‘timestamp’ indicates the time to which the thread was reset to.
if ‘thread_id’ is not included - even applies to ALL user threads
Updated events
posted/post_edited/post_deleted
Additional ‘following’ boolean will be added