[FIX] Delete messages (#1399)

This commit is contained in:
Diego Mello 2019-11-19 12:59:14 -03:00 committed by GitHub
parent e17291960d
commit 29302ccd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import log from '../../utils/log';
import database from '../database'; import database from '../database';
import protectedFunction from './helpers/protectedFunction'; import protectedFunction from './helpers/protectedFunction';
export default function updateMessages({ rid, update, remove }) { export default function updateMessages({ rid, update = [], remove = [] }) {
try { try {
if (!((update && update.length) || (remove && remove.length))) { if (!((update && update.length) || (remove && remove.length))) {
return; return;
@ -22,7 +22,7 @@ export default function updateMessages({ rid, update, remove }) {
console.log('updateMessages: subscription not found'); console.log('updateMessages: subscription not found');
} }
const messagesIds = update.map(m => m._id); const messagesIds = [...update.map(m => m._id), ...remove.map(m => m._id)];
const msgCollection = db.collections.get('messages'); const msgCollection = db.collections.get('messages');
const threadCollection = db.collections.get('threads'); const threadCollection = db.collections.get('threads');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.collections.get('thread_messages');