The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/webdav/client/startup/sync.js

20 lines
701 B

import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { WebdavAccounts } from '../../../models/client';
import { Notifications } from '../../../notifications/client';
import { sdk } from '../../../utils/client/lib/SDKClient';
const events = {
changed: (account) => WebdavAccounts.upsert({ _id: account._id }, account),
removed: ({ _id }) => WebdavAccounts.remove({ _id }),
};
Tracker.autorun(async () => {
if (!Meteor.userId()) {
return;
}
const { accounts } = await sdk.rest.get('/v1/webdav.getMyAccounts');
accounts.forEach((account) => WebdavAccounts.insert(account));
Notifications.onUser('webdav', ({ type, account }) => events[type](account));
});