some fixes

This commit is contained in:
MathMan05
2026-02-04 03:25:48 +01:00
committed by Rory&
parent 0a8ad60e0d
commit eaa2be281f
8 changed files with 35 additions and 21 deletions
@@ -50,7 +50,6 @@ router.post(
where: { id: channel_id },
});
const user = await User.findOneOrFail({ where: { id: req.user_id } });
const recipient = Recipient.create({ channel_id: message.id, user });
const thread = await Channel.createChannel(
{
@@ -78,8 +77,6 @@ router.post(
{ skipPermissionCheck: true, keepId: true, skipEventEmit: true },
);
recipient.save();
message.thread = thread;
message.flags ||= 1 << 5;
await sendMessage({
@@ -533,16 +533,6 @@ 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(
@@ -17,8 +17,8 @@
*/
import { handleMessage, postHandleMessage, route, sendMessage } from "@spacebar/api";
import { Message, Channel, emitEvent, User, MessageUpdateEvent, Recipient, uploadFile, Attachment, Member, ReadState, MessageCreateEvent } from "@spacebar/util";
import { MessageThreadCreationSchema, ChannelType, MessageType, ThreadCreationSchema, MessageCreateAttachment, MessageCreateCloudAttachment } from "@spacebar/schemas";
import { Channel, emitEvent, User, uploadFile, Attachment, Member, ReadState, MessageCreateEvent } from "@spacebar/util";
import { ChannelType, MessageType, ThreadCreationSchema, MessageCreateAttachment, MessageCreateCloudAttachment } from "@spacebar/schemas";
import { Request, Response, Router } from "express";
import { messageUpload } from "./messages";
@@ -81,9 +81,6 @@ router.post(
void 0,
{ skipPermissionCheck: true, keepId: true, skipEventEmit: true },
);
const recipient = Recipient.create({ channel_id: channel.id, user });
await recipient.save();
await Promise.all([
emitEvent({
+1 -1
View File
@@ -243,7 +243,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
if (opts.message_reference.type != 1) {
if (opts.message_reference.guild_id !== channel.guild_id) throw new HTTPError("You can only reference messages from this guild");
if (opts.message_reference.channel_id !== opts.channel_id && opts.type !== MessageType.THREAD_STARTER_MESSAGE)
if (opts.message_reference.channel_id !== opts.channel_id && opts.type !== MessageType.THREAD_STARTER_MESSAGE && opts.type !== MessageType.THREAD_CREATED)
throw new HTTPError("You can only reference messages from this channel");
}