2019-09-16 20:26:32 +00:00
|
|
|
import { Model } from '@nozbe/watermelondb';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { children, date, field, json } from '@nozbe/watermelondb/decorators';
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
import { sanitizer } from '../utils';
|
|
|
|
|
2022-02-01 13:39:09 +00:00
|
|
|
export const SUBSCRIPTIONS_TABLE = 'subscriptions';
|
2021-05-26 17:24:54 +00:00
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
export default class Subscription extends Model {
|
2022-02-01 13:39:09 +00:00
|
|
|
static table = SUBSCRIPTIONS_TABLE;
|
2019-09-16 20:26:32 +00:00
|
|
|
|
|
|
|
static associations = {
|
|
|
|
messages: { type: 'has_many', foreignKey: 'rid' },
|
|
|
|
threads: { type: 'has_many', foreignKey: 'rid' },
|
|
|
|
thread_messages: { type: 'has_many', foreignKey: 'subscription_id' },
|
|
|
|
uploads: { type: 'has_many', foreignKey: 'rid' }
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-09-16 20:26:32 +00:00
|
|
|
|
|
|
|
@field('_id') _id;
|
|
|
|
|
|
|
|
@field('f') f;
|
|
|
|
|
|
|
|
@field('t') t;
|
|
|
|
|
|
|
|
@date('ts') ts;
|
|
|
|
|
|
|
|
@date('ls') ls;
|
|
|
|
|
|
|
|
@field('name') name;
|
|
|
|
|
|
|
|
@field('fname') fname;
|
|
|
|
|
2023-05-29 15:03:24 +00:00
|
|
|
@field('sanitized_fname') sanitizedFname;
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
@field('rid') rid;
|
|
|
|
|
|
|
|
@field('open') open;
|
|
|
|
|
|
|
|
@field('alert') alert;
|
|
|
|
|
|
|
|
@json('roles', sanitizer) roles;
|
|
|
|
|
|
|
|
@field('unread') unread;
|
|
|
|
|
|
|
|
@field('user_mentions') userMentions;
|
|
|
|
|
2020-07-29 20:49:08 +00:00
|
|
|
@field('group_mentions') groupMentions;
|
|
|
|
|
2020-10-30 17:35:07 +00:00
|
|
|
@json('tunread', sanitizer) tunread;
|
|
|
|
|
|
|
|
@json('tunread_user', sanitizer) tunreadUser;
|
|
|
|
|
|
|
|
@json('tunread_group', sanitizer) tunreadGroup;
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
@date('room_updated_at') roomUpdatedAt;
|
|
|
|
|
|
|
|
@field('ro') ro;
|
|
|
|
|
|
|
|
@date('last_open') lastOpen;
|
|
|
|
|
|
|
|
@field('description') description;
|
|
|
|
|
|
|
|
@field('announcement') announcement;
|
|
|
|
|
2020-05-08 12:57:04 +00:00
|
|
|
@field('banner_closed') bannerClosed;
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
@field('topic') topic;
|
|
|
|
|
|
|
|
@field('blocked') blocked;
|
|
|
|
|
|
|
|
@field('blocker') blocker;
|
|
|
|
|
|
|
|
@field('react_when_read_only') reactWhenReadOnly;
|
|
|
|
|
|
|
|
@field('archived') archived;
|
|
|
|
|
|
|
|
@field('join_code_required') joinCodeRequired;
|
|
|
|
|
|
|
|
@field('notifications') notifications;
|
|
|
|
|
|
|
|
@json('muted', sanitizer) muted;
|
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
@json('ignored', sanitizer) ignored;
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
@field('broadcast') broadcast;
|
|
|
|
|
|
|
|
@field('prid') prid;
|
|
|
|
|
|
|
|
@field('draft_message') draftMessage;
|
|
|
|
|
|
|
|
@date('last_thread_sync') lastThreadSync;
|
|
|
|
|
2019-09-18 17:32:12 +00:00
|
|
|
@date('jitsi_timeout') jitsiTimeout;
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
@field('auto_translate') autoTranslate;
|
|
|
|
|
|
|
|
@field('auto_translate_language') autoTranslateLanguage;
|
|
|
|
|
|
|
|
@json('last_message', sanitizer) lastMessage;
|
|
|
|
|
|
|
|
@children('messages') messages;
|
|
|
|
|
|
|
|
@children('threads') threads;
|
|
|
|
|
|
|
|
@children('thread_messages') threadMessages;
|
2019-10-28 20:04:44 +00:00
|
|
|
|
|
|
|
@field('hide_unread_status') hideUnreadStatus;
|
2020-03-06 14:19:03 +00:00
|
|
|
|
2022-06-13 13:24:54 +00:00
|
|
|
@field('hide_mention_status') hideMentionStatus;
|
|
|
|
|
2020-03-06 14:19:03 +00:00
|
|
|
@json('sys_mes', sanitizer) sysMes;
|
2020-04-01 12:28:54 +00:00
|
|
|
|
|
|
|
@json('uids', sanitizer) uids;
|
|
|
|
|
|
|
|
@json('usernames', sanitizer) usernames;
|
2020-05-08 17:36:10 +00:00
|
|
|
|
|
|
|
@json('visitor', sanitizer) visitor;
|
|
|
|
|
|
|
|
@field('department_id') departmentId;
|
|
|
|
|
|
|
|
@json('served_by', sanitizer) servedBy;
|
|
|
|
|
|
|
|
@json('livechat_data', sanitizer) livechatData;
|
|
|
|
|
|
|
|
@json('tags', sanitizer) tags;
|
2020-09-11 14:31:38 +00:00
|
|
|
|
|
|
|
@field('e2e_key') E2EKey;
|
|
|
|
|
2023-01-12 13:32:33 +00:00
|
|
|
@field('e2e_suggested_key') E2ESuggestedKey;
|
|
|
|
|
2020-09-11 14:31:38 +00:00
|
|
|
@field('encrypted') encrypted;
|
|
|
|
|
|
|
|
@field('e2e_key_id') e2eKeyId;
|
2020-10-30 13:51:04 +00:00
|
|
|
|
|
|
|
@field('avatar_etag') avatarETag;
|
2021-04-07 18:31:25 +00:00
|
|
|
|
|
|
|
@field('team_id') teamId;
|
|
|
|
|
|
|
|
@field('team_main') teamMain;
|
2022-04-15 02:27:36 +00:00
|
|
|
|
2022-04-20 20:53:11 +00:00
|
|
|
@field('on_hold') onHold;
|
|
|
|
|
2023-04-28 15:16:14 +00:00
|
|
|
@field('users_count') usersCount;
|
|
|
|
|
2022-04-15 02:27:36 +00:00
|
|
|
@json('source', sanitizer) source;
|
2019-09-16 20:26:32 +00:00
|
|
|
}
|