mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 08:38:37 +00:00
everyoneeee
This commit is contained in:
2
external/revolt.js
vendored
2
external/revolt.js
vendored
Submodule external/revolt.js updated: e650b73359...62d4a668b2
@@ -257,27 +257,31 @@ export default observer(({ channel }: Props) => {
|
|||||||
</Base>
|
</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 (
|
if (
|
||||||
<Base>
|
channel.channel_type != "SavedMessages" &&
|
||||||
<Blocked>
|
((!channel.havePermission("SendMessage") &&
|
||||||
<Action>
|
channel.channel_type == "TextChannel") ||
|
||||||
<PermissionTooltip
|
channel.recipient?.relationship == "Blocked" ||
|
||||||
permission="SendMessages"
|
channel.recipient?.relationship == "BlockedOther")
|
||||||
placement="top">
|
) {
|
||||||
<ShieldX size={22} />
|
return (
|
||||||
</PermissionTooltip>
|
<Base>
|
||||||
</Action>
|
<Blocked>
|
||||||
<div className="text">
|
<Action>
|
||||||
<Text id="app.main.channel.misc.no_sending" />
|
<PermissionTooltip
|
||||||
</div>
|
permission="SendMessages"
|
||||||
</Blocked>
|
placement="top">
|
||||||
</Base>
|
<ShieldX size={22} />
|
||||||
);
|
</PermissionTooltip>
|
||||||
}
|
</Action>
|
||||||
|
<div className="text">
|
||||||
|
<Text id="app.main.channel.misc.no_sending" />
|
||||||
|
</div>
|
||||||
|
</Blocked>
|
||||||
|
</Base>
|
||||||
|
);
|
||||||
|
}
|
||||||
// Push message content to draft.
|
// Push message content to draft.
|
||||||
const setMessage = useCallback(
|
const setMessage = useCallback(
|
||||||
(content?: string) => {
|
(content?: string) => {
|
||||||
@@ -299,9 +303,9 @@ export default observer(({ channel }: Props) => {
|
|||||||
const text =
|
const text =
|
||||||
action === "quote"
|
action === "quote"
|
||||||
? `${content
|
? `${content
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((x) => `> ${x}`)
|
.map((x) => `> ${x}`)
|
||||||
.join("\n")}\n\n`
|
.join("\n")}\n\n`
|
||||||
: `${content} `;
|
: `${content} `;
|
||||||
|
|
||||||
if (!state.draft.has(channel._id)) {
|
if (!state.draft.has(channel._id)) {
|
||||||
@@ -331,17 +335,7 @@ export default observer(({ channel }: Props) => {
|
|||||||
|
|
||||||
// Check for @everyone mentions first
|
// Check for @everyone mentions first
|
||||||
if (content.includes("@everyone")) {
|
if (content.includes("@everyone")) {
|
||||||
// Check if user has permission to mention everyone
|
// kept for potential future logic, but currently does nothing
|
||||||
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
|
||||||
@@ -350,17 +344,19 @@ 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);
|
||||||
// Make sure it's not 'everyone' (already handled)
|
|
||||||
if (username.toLowerCase() !== "everyone") {
|
if (username.toLowerCase() !== "everyone") {
|
||||||
// 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(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
// Replace @username with <@USER_ID>
|
content = content.replace(
|
||||||
content = content.replace(mention, `<@${user._id}>`);
|
mention,
|
||||||
|
`<@${user._id}>`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,8 +388,8 @@ export default observer(({ channel }: Props) => {
|
|||||||
toReplace == ""
|
toReplace == ""
|
||||||
? msg.content.toString() + newText
|
? msg.content.toString() + newText
|
||||||
: msg.content
|
: msg.content
|
||||||
.toString()
|
.toString()
|
||||||
.replace(new RegExp(toReplace, flags), newText);
|
.replace(new RegExp(toReplace, flags), newText);
|
||||||
|
|
||||||
if (newContent != msg.content) {
|
if (newContent != msg.content) {
|
||||||
if (newContent.length == 0) {
|
if (newContent.length == 0) {
|
||||||
@@ -475,10 +471,10 @@ export default observer(({ channel }: Props) => {
|
|||||||
files,
|
files,
|
||||||
percent: Math.round(
|
percent: Math.round(
|
||||||
(i * 100 + (100 * e.loaded) / e.total) /
|
(i * 100 + (100 * e.loaded) / e.total) /
|
||||||
Math.min(
|
Math.min(
|
||||||
files.length,
|
files.length,
|
||||||
CAN_UPLOAD_AT_ONCE,
|
CAN_UPLOAD_AT_ONCE,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
cancel,
|
cancel,
|
||||||
}),
|
}),
|
||||||
@@ -769,13 +765,13 @@ export default observer(({ channel }: Props) => {
|
|||||||
placeholder={
|
placeholder={
|
||||||
channel.channel_type === "DirectMessage"
|
channel.channel_type === "DirectMessage"
|
||||||
? translate("app.main.channel.message_who", {
|
? translate("app.main.channel.message_who", {
|
||||||
person: channel.recipient?.username,
|
person: channel.recipient?.username,
|
||||||
})
|
})
|
||||||
: channel.channel_type === "SavedMessages"
|
: channel.channel_type === "SavedMessages"
|
||||||
? translate("app.main.channel.message_saved")
|
? translate("app.main.channel.message_saved")
|
||||||
: translate("app.main.channel.message_where", {
|
: translate("app.main.channel.message_where", {
|
||||||
channel_name: channel.name ?? undefined,
|
channel_name: channel.name ?? undefined,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
uploadState.type === "uploading" ||
|
uploadState.type === "uploading" ||
|
||||||
|
|||||||
@@ -164,14 +164,6 @@ export default class State {
|
|||||||
|
|
||||||
// Register events for notifications.
|
// Register events for notifications.
|
||||||
client.addListener("message", this.notifications.onMessage);
|
client.addListener("message", this.notifications.onMessage);
|
||||||
client.addListener(
|
|
||||||
"message/mention",
|
|
||||||
this.notifications.onMessage,
|
|
||||||
);
|
|
||||||
client.addListener(
|
|
||||||
"message/mention/everyone",
|
|
||||||
this.notifications.onMessage,
|
|
||||||
);
|
|
||||||
client.addListener(
|
client.addListener(
|
||||||
"user/relationship",
|
"user/relationship",
|
||||||
this.notifications.onRelationship,
|
this.notifications.onRelationship,
|
||||||
@@ -276,14 +268,6 @@ export default class State {
|
|||||||
client.removeListener("message", this.queue.onMessage);
|
client.removeListener("message", this.queue.onMessage);
|
||||||
client.removeListener("packet", this.onPacket);
|
client.removeListener("packet", this.onPacket);
|
||||||
client.removeListener("message", this.notifications.onMessage);
|
client.removeListener("message", this.notifications.onMessage);
|
||||||
client.removeListener(
|
|
||||||
"message/mention",
|
|
||||||
this.notifications.onMessage,
|
|
||||||
);
|
|
||||||
client.removeListener(
|
|
||||||
"message/mention/everyone",
|
|
||||||
this.notifications.onMessage,
|
|
||||||
);
|
|
||||||
client.removeListener(
|
client.removeListener(
|
||||||
"user/relationship",
|
"user/relationship",
|
||||||
this.notifications.onRelationship,
|
this.notifications.onRelationship,
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export default class NotificationOptions
|
|||||||
|
|
||||||
// Check channel notification settings
|
// Check channel notification settings
|
||||||
const mentioned = message.mention_ids?.includes(user._id) ||
|
const mentioned = message.mention_ids?.includes(user._id) ||
|
||||||
(message as any).mentionsEveryone;
|
message.mentionsEveryone;
|
||||||
switch (this.computeForChannel(message.channel!)) {
|
switch (this.computeForChannel(message.channel!)) {
|
||||||
case "muted":
|
case "muted":
|
||||||
case "none":
|
case "none":
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import isEqual from "lodash.isequal";
|
import isEqual from "lodash.isequal";
|
||||||
import { observer } from "mobx-react-lite";
|
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 { Text } from "preact-i18n";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
@@ -100,7 +100,7 @@ export default observer(({ channel }: Props) => {
|
|||||||
filter={[
|
filter={[
|
||||||
...(channel.channel_type === "Group"
|
...(channel.channel_type === "Group"
|
||||||
? []
|
? []
|
||||||
: ["ViewChannel" as const]),
|
: ["ViewChannel", "MentionEveryone"]),
|
||||||
"ReadMessageHistory",
|
"ReadMessageHistory",
|
||||||
"SendMessage",
|
"SendMessage",
|
||||||
"ManageMessages",
|
"ManageMessages",
|
||||||
@@ -109,10 +109,9 @@ export default observer(({ channel }: Props) => {
|
|||||||
"UploadFiles",
|
"UploadFiles",
|
||||||
"Masquerade",
|
"Masquerade",
|
||||||
"React",
|
"React",
|
||||||
"MentionEveryone",
|
|
||||||
"ManageChannel",
|
"ManageChannel",
|
||||||
"ManagePermissions",
|
"ManagePermissions",
|
||||||
]}
|
] as (keyof typeof Permission)[]}
|
||||||
target={channel}
|
target={channel}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user