Skip to content

Commit

Permalink
Step 5.24: Add senderId property to addMessage method
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and DAB0mB committed Feb 26, 2017
1 parent 38a0009 commit fa20568
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/imports/methods/methods.ts
Expand Up @@ -24,6 +24,9 @@ Meteor.methods({
});
},
addMessage(chatId: string, content: string): void {
if (!this.userId) throw new Meteor.Error('unauthorized',
'User must be logged-in to create a new chat');

check(chatId, nonEmptyString);
check(content, nonEmptyString);

Expand All @@ -34,6 +37,7 @@ Meteor.methods({

Messages.collection.insert({
chatId: chatId,
senderId: this.userId,
content: content,
createdAt: new Date()
});
Expand Down

0 comments on commit fa20568

Please sign in to comment.