vn-verdnaturachat/app/lib/methods/readMessages.js

25 lines
649 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 {
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);
}
}