Permalink
Browse files

Step 9.2: Add removeChat method on server side

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent 11a5147 commit 796f94986936c75f1c5bc5c7ca8c6ae6ec9cd1e8
Showing with 17 additions and 0 deletions.
  1. +17 −0 api/server/methods.ts
View
@@ -37,6 +37,23 @@ Meteor.methods({
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');
}
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 796f949

Please sign in to comment.