Skip to content

Commit

Permalink
Step 9.2: Add removeChat method on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and darkbasic committed Oct 16, 2017
1 parent 11a5147 commit 796f949
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api/server/methods.ts
Expand Up @@ -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');
Expand Down

0 comments on commit 796f949

Please sign in to comment.