|
@@ -4,6 +4,8 @@ ChatManager = class ChatManager {
|
|
|
*
|
|
|
* @param {Collection} chats
|
|
|
* A Chats collection instance.
|
|
|
+ *
|
|
|
+ * @returns {void}
|
|
|
*/
|
|
|
constructor(chats) {
|
|
|
this.chats = chats;
|
|
@@ -58,14 +60,25 @@ ChatManager = class ChatManager {
|
|
|
throw new Meteor.Error("access-denied", "Could not insert new chat.");
|
|
|
}
|
|
|
session.set("chatId", chatId);
|
|
|
- console.log("--- No chat found between " + user1Id + " and " + user2Id + ". Created " + chatId);
|
|
|
+ console.log("-- No chat found between " + user1Id + " and " + user2Id + ". Created " + chatId);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
const chatId = chat._id;
|
|
|
session.set("chatId", chatId);
|
|
|
- console.log("--- Chat " + chatId + " found between " + user1Id + " and " + user2Id + ".");
|
|
|
+ console.log("-- Chat " + chatId + " found between " + user1Id + " and " + user2Id + ".");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ static insertMethod(chat) {
|
|
|
+ check(chat, {
|
|
|
+ user1Id: String,
|
|
|
+ user2Id: String
|
|
|
+ });
|
|
|
+ chat.messages = [];
|
|
|
+ const chatId = Chats.insert(chat);
|
|
|
+
|
|
|
+ return chatId;
|
|
|
+ }
|
|
|
};
|