everyoneeee

pull/1154/head
NanoAim 2025-07-13 03:56:42 +08:00
parent d63ad05417
commit 2475a36e50
5 changed files with 53 additions and 74 deletions

2
external/revolt.js vendored

@ -1 +1 @@
Subproject commit e650b73359fe1a17f4b47a9df964c98a627316d4
Subproject commit 62d4a668b2115227b7d13e5551923b676d1d8adf

View File

@ -257,27 +257,31 @@ export default observer(({ channel }: Props) => {
</Base>
);
}
console.log(channel) //|| channel.channel_type != "DirectMessage"
if (channel.channel_type != "SavedMessages")
if (!channel.havePermission("SendMessage") && channel.channel_type == "TextChannel" || channel.recipient?.relationship == "Blocked" || channel.recipient?.relationship == "BlockedOther") {
return (
<Base>
<Blocked>
<Action>
<PermissionTooltip
permission="SendMessages"
placement="top">
<ShieldX size={22} />
</PermissionTooltip>
</Action>
<div className="text">
<Text id="app.main.channel.misc.no_sending" />
</div>
</Blocked>
</Base>
);
}
if (
channel.channel_type != "SavedMessages" &&
((!channel.havePermission("SendMessage") &&
channel.channel_type == "TextChannel") ||
channel.recipient?.relationship == "Blocked" ||
channel.recipient?.relationship == "BlockedOther")
) {
return (
<Base>
<Blocked>
<Action>
<PermissionTooltip
permission="SendMessages"
placement="top">
<ShieldX size={22} />
</PermissionTooltip>
</Action>
<div className="text">
<Text id="app.main.channel.misc.no_sending" />
</div>
</Blocked>
</Base>
);
}
// Push message content to draft.
const setMessage = useCallback(
(content?: string) => {
@ -299,9 +303,9 @@ export default observer(({ channel }: Props) => {
const text =
action === "quote"
? `${content
.split("\n")
.map((x) => `> ${x}`)
.join("\n")}\n\n`
.split("\n")
.map((x) => `> ${x}`)
.join("\n")}\n\n`
: `${content} `;
if (!state.draft.has(channel._id)) {
@ -331,17 +335,7 @@ export default observer(({ channel }: Props) => {
// Check for @everyone mentions first
if (content.includes("@everyone")) {
// Check if user has permission to mention everyone
if (!channel.havePermission("MentionEveryone")) {
// Display error toast when no permission
modalController.push({
type: "error",
error: client.i18n.t("app.main.channel.misc.no_everyone_mention"),
});
// Remove @everyone from the message when no permission
content = content.replace(/@everyone/g, "everyone");
}
// If user has permission, keep @everyone as is (don't wrap in <>)
// kept for potential future logic, but currently does nothing
}
// Convert @username mentions to <@USER_ID> format
@ -350,17 +344,19 @@ export default observer(({ channel }: Props) => {
if (mentionMatches) {
for (const mention of mentionMatches) {
const username = mention.substring(1); // Remove the @ symbol
// Make sure it's not 'everyone' (already handled)
const username = mention.substring(1);
if (username.toLowerCase() !== "everyone") {
// Find the user with this username
const user = Array.from(client.users.values()).find(
(u) => u.username.toLowerCase() === username.toLowerCase()
(u) =>
u.username.toLowerCase() ===
username.toLowerCase(),
);
if (user) {
// Replace @username with <@USER_ID>
content = content.replace(mention, `<@${user._id}>`);
content = content.replace(
mention,
`<@${user._id}>`,
);
}
}
}
@ -392,8 +388,8 @@ export default observer(({ channel }: Props) => {
toReplace == ""
? msg.content.toString() + newText
: msg.content
.toString()
.replace(new RegExp(toReplace, flags), newText);
.toString()
.replace(new RegExp(toReplace, flags), newText);
if (newContent != msg.content) {
if (newContent.length == 0) {
@ -475,10 +471,10 @@ export default observer(({ channel }: Props) => {
files,
percent: Math.round(
(i * 100 + (100 * e.loaded) / e.total) /
Math.min(
files.length,
CAN_UPLOAD_AT_ONCE,
),
Math.min(
files.length,
CAN_UPLOAD_AT_ONCE,
),
),
cancel,
}),
@ -769,13 +765,13 @@ export default observer(({ channel }: Props) => {
placeholder={
channel.channel_type === "DirectMessage"
? translate("app.main.channel.message_who", {
person: channel.recipient?.username,
})
person: channel.recipient?.username,
})
: channel.channel_type === "SavedMessages"
? translate("app.main.channel.message_saved")
: translate("app.main.channel.message_where", {
channel_name: channel.name ?? undefined,
})
? translate("app.main.channel.message_saved")
: translate("app.main.channel.message_where", {
channel_name: channel.name ?? undefined,
})
}
disabled={
uploadState.type === "uploading" ||

View File

@ -164,14 +164,6 @@ export default class State {
// Register events for notifications.
client.addListener("message", this.notifications.onMessage);
client.addListener(
"message/mention",
this.notifications.onMessage,
);
client.addListener(
"message/mention/everyone",
this.notifications.onMessage,
);
client.addListener(
"user/relationship",
this.notifications.onRelationship,
@ -276,14 +268,6 @@ export default class State {
client.removeListener("message", this.queue.onMessage);
client.removeListener("packet", this.onPacket);
client.removeListener("message", this.notifications.onMessage);
client.removeListener(
"message/mention",
this.notifications.onMessage,
);
client.removeListener(
"message/mention/everyone",
this.notifications.onMessage,
);
client.removeListener(
"user/relationship",
this.notifications.onRelationship,

View File

@ -158,7 +158,7 @@ export default class NotificationOptions
// Check channel notification settings
const mentioned = message.mention_ids?.includes(user._id) ||
(message as any).mentionsEveryone;
message.mentionsEveryone;
switch (this.computeForChannel(message.channel!)) {
case "muted":
case "none":

View File

@ -1,6 +1,6 @@
import isEqual from "lodash.isequal";
import { observer } from "mobx-react-lite";
import { Channel, API, DEFAULT_PERMISSION_DIRECT_MESSAGE } from "revolt.js";
import { Channel, API, DEFAULT_PERMISSION_DIRECT_MESSAGE, Permission } from "revolt.js";
import { Text } from "preact-i18n";
import { useState } from "preact/hooks";
@ -100,7 +100,7 @@ export default observer(({ channel }: Props) => {
filter={[
...(channel.channel_type === "Group"
? []
: ["ViewChannel" as const]),
: ["ViewChannel", "MentionEveryone"]),
"ReadMessageHistory",
"SendMessage",
"ManageMessages",
@ -109,10 +109,9 @@ export default observer(({ channel }: Props) => {
"UploadFiles",
"Masquerade",
"React",
"MentionEveryone",
"ManageChannel",
"ManagePermissions",
]}
] as (keyof typeof Permission)[]}
target={channel}
/>
</div>