Skip to content

Commit

Permalink
Step 7.28: Added restriction on new message method
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB committed Feb 26, 2017
1 parent 2f9ec6c commit 10e8020
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/methods.ts
Expand Up @@ -23,6 +23,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);
Expand All @@ -37,6 +40,7 @@ Meteor.methods({
return {
messageId: Messages.collection.insert({
chatId: chatId,
senderId: this.userId,
content: content,
createdAt: new Date(),
type: type
Expand Down

0 comments on commit 10e8020

Please sign in to comment.