mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-10 10:35:27 +00:00
fix <> wrapper
This commit is contained in:
@@ -329,6 +329,21 @@ export default observer(({ channel }: Props) => {
|
|||||||
if (uploadState.type !== "none") return sendFile(content);
|
if (uploadState.type !== "none") return sendFile(content);
|
||||||
if (content.length === 0) return;
|
if (content.length === 0) return;
|
||||||
|
|
||||||
|
// 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 <>)
|
||||||
|
}
|
||||||
|
|
||||||
// Convert @username mentions to <@USER_ID> format
|
// Convert @username mentions to <@USER_ID> format
|
||||||
const mentionRegex = /@([a-zA-Z0-9_]+)/g;
|
const mentionRegex = /@([a-zA-Z0-9_]+)/g;
|
||||||
const mentionMatches = content.match(mentionRegex);
|
const mentionMatches = content.match(mentionRegex);
|
||||||
@@ -336,6 +351,8 @@ export default observer(({ channel }: Props) => {
|
|||||||
if (mentionMatches) {
|
if (mentionMatches) {
|
||||||
for (const mention of mentionMatches) {
|
for (const mention of mentionMatches) {
|
||||||
const username = mention.substring(1); // Remove the @ symbol
|
const username = mention.substring(1); // Remove the @ symbol
|
||||||
|
// Make sure it's not 'everyone' (already handled)
|
||||||
|
if (username.toLowerCase() !== "everyone") {
|
||||||
// Find the user with this username
|
// Find the user with this username
|
||||||
const user = Array.from(client.users.values()).find(
|
const user = Array.from(client.users.values()).find(
|
||||||
(u) => u.username.toLowerCase() === username.toLowerCase()
|
(u) => u.username.toLowerCase() === username.toLowerCase()
|
||||||
@@ -347,6 +364,7 @@ export default observer(({ channel }: Props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internalEmit("NewMessages", "hide");
|
internalEmit("NewMessages", "hide");
|
||||||
stopTyping();
|
stopTyping();
|
||||||
|
|||||||
Reference in New Issue
Block a user