Skip to content

Commit

Permalink
feat: add publish on send message
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcanali committed Feb 18, 2024
1 parent 4588014 commit 92a9978
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/src/api/routes/send-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FastifyInstance } from "fastify";
import z from "zod";
import { prisma } from "../../lib/prisma";
import { randomUUID } from "crypto";
import { messageDisplay } from "../../utils/message-pub-sub";

export async function sendMessage(app: FastifyInstance) {
app.post('/api/message/:channel', async (request, reply) => {
Expand Down Expand Up @@ -50,6 +51,12 @@ export async function sendMessage(app: FastifyInstance) {
}
})

messageDisplay.publish(channel, {
userId: message.userId,
content: message.content,
created_at: message.created_at
})

return reply.status(201).send({
message,
sessionCookieId,
Expand Down

0 comments on commit 92a9978

Please sign in to comment.