Skip to content

Commit

Permalink
Step 4.23: Add new message method to api
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB authored and Dotan Simha committed Nov 22, 2016
1 parent 2e7ce66 commit 3fa1ab2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/server/methods.js
@@ -0,0 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { Chats, Messages } from './collections';

Meteor.methods({
newMessage(message) {
message.timestamp = new Date();

const messageId = Messages.insert(message);
Chats.update(message.chatId, { $set: { lastMessage: message } });

return messageId;
}
});

0 comments on commit 3fa1ab2

Please sign in to comment.