feat: add realtime with socket.io

This commit is contained in:
Divlo
2022-01-13 16:33:16 +00:00
parent 97b1d04261
commit 5643ab420f
7 changed files with 483 additions and 363 deletions

View File

@ -102,7 +102,7 @@ export const postMessageByChannelIdService: FastifyPluginAsync = async (
}
})
reply.statusCode = 201
return {
const item = {
...message,
member: {
...memberCheck,
@ -112,6 +112,12 @@ export const postMessageByChannelIdService: FastifyPluginAsync = async (
}
}
}
await fastify.io.emitToMembers({
event: 'messages',
guildId: item.member.guildId,
payload: { action: 'create', item }
})
return item
}
})
}

View File

@ -107,7 +107,7 @@ export const postMessageUploadsByChannelIdService: FastifyPluginAsync = async (
}
})
reply.statusCode = 201
return {
const item = {
...message,
member: {
...memberCheck,
@ -117,6 +117,12 @@ export const postMessageUploadsByChannelIdService: FastifyPluginAsync = async (
}
}
}
await fastify.io.emitToMembers({
event: 'messages',
guildId: item.member.guildId,
payload: { action: 'create', item }
})
return item
}
})
}