26 lines
664 B
JavaScript
26 lines
664 B
JavaScript
import * as SDK from '@rocket.chat/sdk';
|
|
|
|
import database from '../realm';
|
|
import log from '../../utils/log';
|
|
|
|
export default async function readMessages(rid) {
|
|
const ls = new Date();
|
|
try {
|
|
// RC 0.61.0
|
|
const data = await SDK.api.post('subscriptions.read', { rid });
|
|
const [subscription] = database.objects('subscriptions').filtered('rid = $0', rid);
|
|
database.write(() => {
|
|
subscription.open = true;
|
|
subscription.alert = false;
|
|
subscription.unread = 0;
|
|
subscription.userMentions = 0;
|
|
subscription.groupMentions = 0;
|
|
subscription.ls = ls;
|
|
subscription.lastOpen = ls;
|
|
});
|
|
return data;
|
|
} catch (e) {
|
|
log('readMessages', e);
|
|
}
|
|
}
|