everyoneeee

This commit is contained in:
NanoAim
2025-07-13 03:56:42 +08:00
parent d63ad05417
commit 2475a36e50
5 changed files with 53 additions and 74 deletions

View File

@@ -257,10 +257,14 @@ 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") {
if (
channel.channel_type != "SavedMessages" &&
((!channel.havePermission("SendMessage") &&
channel.channel_type == "TextChannel") ||
channel.recipient?.relationship == "Blocked" ||
channel.recipient?.relationship == "BlockedOther")
) {
return (
<Base>
<Blocked>
@@ -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}>`,
);
}
}
}

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>