Skip to content

Commit

Permalink
Step 5.28: Add senderId property to addMessage method
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 26, 2017
1 parent a3f7674 commit 20c7892
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/server/methods.ts
Expand Up @@ -24,6 +24,9 @@ export function initMethods() {
});
},
addMessage(chatId: string, content: string) {
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 @@ export function initMethods() {

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

0 comments on commit 20c7892

Please sign in to comment.