Skip to content
Permalink
Browse files

Step 7.2: Define 'removeChat' Method

  • Loading branch information...
dotansimha authored and DAB0mB committed Nov 3, 2016
1 parent 4af70b3 commit e06df6f97892a1f142b82a0dff79efc4e96a4cf1
Showing with 14 additions and 0 deletions.
  1. +14 −0 api/server/methods.ts
@@ -32,6 +32,20 @@ export function initMethods() {

Chats.insert(chat);
},
removeChat(chatId: string): void {
if (!this.userId) throw new Meteor.Error('unauthorized',
'User must be logged-in to remove chat');

check(chatId, nonEmptyString);

const chatExists = !!Chats.collection.find(chatId).count();

if (!chatExists) throw new Meteor.Error('chat-not-exists',
'Chat doesn\'t exist');

Messages.remove({chatId});
Chats.remove(chatId);
},
updateProfile(profile: Profile): void {
if (!this.userId) throw new Meteor.Error('unauthorized',
'User must be logged-in to create a new chat');

0 comments on commit e06df6f

Please sign in to comment.
You can’t perform that action at this time.