The subscription object contains information about the room and the user in relation to it. This is stored in the rocketchat_subscription
collection on MongoDB.
Interface
interface ISubscription {
u: Pick<IUser, '_id' | 'username' | 'name'>;
v?: Pick<IUser, '_id' | 'username' | 'name'>;
rid: RoomID;
open: boolean;
ts: Date;
name: string;
alert?: boolean;
unread: number;
t: RoomType;
ls: Date;
f?: boolean;
lr: Date;
hideUnreadStatus?: true;
hideMentionStatus?: true;
teamMain?: boolean;
teamId?: string;
userMentions: number;
groupMentions: number;
broadcast?: true;
tunread?: Array<string>;
tunreadGroup?: Array<string>;
tunreadUser?: Array<string>;
prid?: RoomID;
roles?: IRole['_id'][];
onHold?: boolean;
encrypted?: boolean;
E2EKey?: string;
E2ESuggestedKey?: string;
unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing';
fname?: string;
code?: unknown;
archived?: boolean;
audioNotificationValue?: string;
desktopNotifications?: 'all' | 'mentions' | 'nothing';
mobilePushNotifications?: 'all' | 'mentions' | 'nothing';
emailNotifications?: 'all' | 'mentions' | 'nothing';
userHighlights?: string[];
blocked?: unknown;
blocker?: unknown;
autoTranslate?: boolean;
autoTranslateLanguage?: string;
disableNotifications?: boolean;
muteGroupMentions?: boolean;
ignored?: IUser['_id'][];
department?: unknown;
desktopPrefOrigin?: 'subscription' | 'user';
mobilePrefOrigin?: 'subscription' | 'user';
emailPrefOrigin?: 'subscription' | 'user';
/* @deprecated */
customFields?: Record<string, any>;
}
You can check the ISubscription
interface here.
Rocket.Chat/ISubscription.ts at develop · RocketChat/Rocket.Chat
Subscription object
Example object
{
"_id": "GuZJ5YcMHe4iRDbMm",
"open": true,
"alert": true,
"unread": 1,
"userMentions": 1,
"groupMentions": 0,
"ts": {
"$date": "2023-02-06T14:17:44.985Z"
},
"rid": "GENERAL",
"name": "general",
"t": "c",
"u": {
"_id": "6LMJ5Lu5YsBaqsJvE",
"username": "user1"
},
"_updatedAt": {
"$date": "2023-02-06T14:17:44.985Z"
}
}
Fields
Parameter | Data type | Description |
---|---|---|
| String | Unique identifier for the subscription. |
| Object | Information about the user associated with the subscription (_id, username, name). |
| Object | Information about the visitor associated with the subscription (_id, username, name). |
| String | The room ID associated with the subscription. |
| Boolean | Indicates if the room is open for the user(it defaults to false on direct messages). Clients use this to determine whether the user can see this subscription in their list since you can hide rooms from being visible without leaving them. |
| Date | The timestamp the room was created at, so this should equal the room's |
| String | Name of the subscription. |
| Boolean | Indicates if there is an alert for the subscription to be displayed to the user. |
| Number | Number of unread messages in the subscription. |
| String | Type of room associated with the subscription (e.g., "c" for channel, "d" for direct message. See Room Schema Definition). |
| Date | Timestamp of the last seen activity in the subscription. |
| Boolean | Indicates if the subscription is a favorite. |
| Date | Timestamp of the last reply in a thread. |
| Boolean | Whether the subscribed room should be marked as containing unread messages in the UI or not. |
| Boolean | Indicates if the mention status is hidden. |
| Boolean | Whether this subscription points to the main room of a team or not. |
| String | (Optional) ID of the team associated with the subscription, if the subscription points to a team room. |
| Number | Number of unread mentions to the user in the room. |
| Number | Number of unread mentions to a group which the user is part of (e.g |
| Boolean | Indicates if the subscription is a broadcast. |
| Array of string | (Optional) List of IDs of unread threads. |
| Array of string | (Optional) List of thread IDs that contain an unread mention to a group that the user is part of. |
| Array of string | (Optional) List of thread IDs that contain an unread mention to the user. |
| String | Parent room ID. This will only be available if this is a subscription to a discussion. |
| Array of string | An array of role IDs associated with the subscription. |
| Boolean | (Omnichannel) Whether or not this room has been put on hold. |
| Boolean | Indicates if the subscription is encrypted. |
| String | Encryption key for the subscription. |
| String | Suggested encryption key for the subscription. |
| String | Type of alert for unread messages in the subscription (default, all, mentions, nothing). |
| String | Friendly name of the subscription. |
| unknown | Unknown data type. |
| Boolean | Indicates if the subscription is archived. |
| String | Value for audio notifications. |
| String | Desktop notification preferences for the subscription (all, mentions, nothing). |
| String | Mobile push notification preferences for the subscription (all, mentions, nothing). |
| String | Email notification preferences for the subscription (all, mentions, nothing). |
| Array of string | An array of user IDs to highlight in the subscription. |
| unknown | Unknown data type. |
| unknown | Unknown data type. |
| Boolean | Indicates if auto-translation is enabled for the subscription. |
| String | Language code for auto-translation in the subscription. |
| Boolean | Indicates if notifications are disabled for the subscription. |
| Boolean | Indicates if group mentions are muted for the subscription. |
| Array of string | An array of user IDs to ignore in the subscription. |
| unknown | Unknown data type. |
| String | Origin of the desktop preference (subscription or user). |
| String | Origin of the mobile preference (subscription or user). |
| String | Origin of the email preference (subscription or user). |
| Record<string, any> | Custom fields associated with the subscription. |
Notes about
customFields
:
customFields
inherits from room's custom fields for channels (Room Type: c = chanel) and groups (Room Type: p = group) and changes with room's custom fields.
customFields
inherits from user's custom fields for direct messages (Room Type: d = direct) and changes with user's custom fields. Note that users of DM rooms will have own custom fields.