2018-10-15 20:22:42 +00:00
|
|
|
import * as SDK from '@rocket.chat/sdk';
|
|
|
|
|
2018-04-24 19:34:03 +00:00
|
|
|
import database from '../realm';
|
2018-05-18 17:55:08 +00:00
|
|
|
import log from '../../utils/log';
|
2018-04-24 19:34:03 +00:00
|
|
|
|
|
|
|
export default async function readMessages(rid) {
|
2018-10-15 20:22:42 +00:00
|
|
|
const ls = new Date();
|
2018-05-18 17:55:08 +00:00
|
|
|
try {
|
2018-12-21 10:55:35 +00:00
|
|
|
// RC 0.61.0
|
2018-12-05 20:52:08 +00:00
|
|
|
const data = await SDK.api.post('subscriptions.read', { rid });
|
|
|
|
const [subscription] = database.objects('subscriptions').filtered('rid = $0', rid);
|
|
|
|
database.write(() => {
|
2018-05-18 17:55:08 +00:00
|
|
|
subscription.open = true;
|
|
|
|
subscription.alert = false;
|
|
|
|
subscription.unread = 0;
|
|
|
|
subscription.userMentions = 0;
|
|
|
|
subscription.groupMentions = 0;
|
2018-10-15 20:22:42 +00:00
|
|
|
subscription.ls = ls;
|
|
|
|
subscription.lastOpen = ls;
|
2018-05-18 17:55:08 +00:00
|
|
|
});
|
|
|
|
return data;
|
|
|
|
} catch (e) {
|
|
|
|
log('readMessages', e);
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|