summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2025-12-11 22:00:33 -0600
committerRory& <root@rory.gay>2026-01-28 21:47:47 +0100
commit9bd97516fff36f092c98ac2be14e9d26a36b1235 (patch)
treeae899258f796f5cb142e502ef9068690045bc5ca /src/api
parentinitial recipients work (diff)
downloadserver-ts-dev/threads.tar.xz
Diffstat (limited to '')
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index 9a1174cb2..00241149e 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -41,6 +41,7 @@ import { stringGlobToRegexp, uploadFile, User, + Recipient, } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; @@ -59,6 +60,7 @@ import { Reaction, ReadStateType, RelationshipType, + ChannelType, } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); @@ -472,6 +474,16 @@ router.post( // no await as it shouldnt block the message send function and silently catch error postHandleMessage(message).catch((e) => console.error("[Message] post-message handler failed", e)); + if (channel.type === ChannelType.GUILD_PUBLIC_THREAD && channel.recipients && !channel.recipients.find((_) => _.user.id === req.user_id)) { + const rec = Recipient.create({ + channel_id: channel.id, + user_id: req.user_id, + }); + channel.recipients.push(rec); + rec.save().then(() => { + channel.save(); + }); + } return res.json( message.withSignedAttachments(