Add chatCreate socket event

pull/4/head
trivernis 5 years ago
parent 0f4f4fb9f1
commit 8a35195040

@ -5,7 +5,9 @@ const mdEmoji = require("markdown-it-emoji");
namespace markdown {
const md = new MarkdownIt()
const md = new MarkdownIt({
linkify: true,
})
.use(html5Media)
.use(mdEmoji);

@ -47,6 +47,12 @@ class HomeRoute extends Route {
globals.internalEmitter.on(InternalEvents.GQLPOSTCREATE, async (post: Post) => {
socket.emit("post", Object.assign(post, {htmlContent: post.htmlContent}));
});
globals.internalEmitter.on(InternalEvents.CHATCREATE, async (chat: ChatRoom) => {
const user = await User.findByPk(socket.handshake.session.userId);
if (await chat.$has("rMembers", user)) {
socket.emit("chatCreate", chat);
}
});
});
const chats = await dataaccess.getAllChats();

Loading…
Cancel
Save