Permalink
Browse files

Step 7.29: Added restriction on new message method

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent 8d50ffb commit 1b58035d26024c9febceebe7138e7261b9c070e1
Showing with 4 additions and 0 deletions.
  1. +4 −0 api/server/methods.ts
@@ -22,6 +22,9 @@ Meteor.methods({
});
},
addMessage(type: MessageType, chatId: string, content: string) {
if (!this.userId) throw new Meteor.Error('unauthorized',
'User must be logged-in to create a new chat');
check(type, Match.OneOf(String, [ MessageType.TEXT ]));
check(chatId, nonEmptyString);
check(content, nonEmptyString);
@@ -36,6 +39,7 @@ Meteor.methods({
return {
messageId: Messages.collection.insert({
chatId: chatId,
senderId: this.userId,
content: content,
createdAt: new Date(),
type: type

0 comments on commit 1b58035

Please sign in to comment.