summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2025-11-19 11:42:08 -0600
committerMathMan05 <mathmanrm@gmail.com>2025-11-19 11:42:08 -0600
commita5b51295425c6da9cd19c5489752dbcb7648bda0 (patch)
tree66682a3671e2d5d0177fb485fce4faa071df4ead /src/api
parentadd missing awaits (diff)
downloadserver-ts-a5b51295425c6da9cd19c5489752dbcb7648bda0.tar.xz
fixes
Diffstat (limited to 'src/api')
-rw-r--r--src/api/util/handlers/Message.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts

index 47623298..6ba66985 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -49,6 +49,7 @@ import fetch from "node-fetch-commonjs"; import { CloudAttachment } from "../../../util/entities/CloudAttachment"; import { ReadState } from "../../../util/entities/ReadState"; import { Member } from "../../../util/entities/Member"; +import { Session } from "../../../util/entities/Session"; import { ChannelType } from "@spacebar/schemas"; import { Embed, MessageCreateAttachment, MessageCreateCloudAttachment, MessageCreateSchema, MessageType, Reaction } from "@spacebar/schemas"; import { EmbedType } from "../../../schemas/api/messages/Embeds"; @@ -340,7 +341,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { }), ); } - if (!!message.content?.match(EVERYONE_MENTION) || channel.type === ChannelType.DM || channel.type === ChannelType.GROUP_DM) { + if ((!!message.content?.match(EVERYONE_MENTION) && permission?.has("MENTION_EVERYONE")) || channel.type === ChannelType.DM || channel.type === ChannelType.GROUP_DM) { if (channel.type === ChannelType.DM || channel.type === ChannelType.GROUP_DM) { if (channel.recipients) { await fillInMissingIDs(channel.recipients.map(({ user_id }) => user_id)); @@ -367,6 +368,10 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { ).map((member) => member.id), ...message.mentions.map((user) => user.id), ]); + if (!!message.content?.match(HERE_MENTION) && permission?.has("MENTION_EVERYONE")) { + const ids = (await Member.find({ where: { guild_id: channel.guild_id } })).map(({ id }) => id); + (await Session.find({ where: { user_id: Or(...ids.map((id) => Equal(id))) } })).forEach(({ user_id }) => users.add(user_id)); + } if (users.size) { const repository = ReadState.getRepository(); const condition = { user_id: Or(...[...users].map((id) => Equal(id))), channel_id: channel.id };