Allow DMing non friends

pull/1049/head
Anonymous 2024-08-30 15:55:56 +08:00
parent 86a8245e3d
commit 6bca2e56f8
2 changed files with 21 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import { HappyBeaming, Send, ShieldX } from "@styled-icons/boxicons-solid";
import Axios, { CancelTokenSource } from "axios";
import { observer } from "mobx-react-lite";
import { Channel } from "revolt.js";
import { Channel, User } from "revolt.js";
import styled, { css } from "styled-components/macro";
import { ulid } from "ulid";
@ -229,6 +229,19 @@ export default observer(({ channel }: Props) => {
const renderer = getRenderer(channel);
const isBlocked = () => {
if (channel.channel_type === "DirectMessage") {
const recipient = channel.recipient;
if (recipient instanceof User) {
return (
recipient.relationship === "Blocked" ||
recipient.relationship === "BlockedOther"
);
}
}
return false;
};
if (channel.server?.member?.timeout) {
return (
<Base>
@ -257,7 +270,12 @@ export default observer(({ channel }: Props) => {
);
}
if (!channel.havePermission("SendMessage")) {
if (
(channel.channel_type !== "DirectMessage" &&
channel.channel_type !== "Group" &&
!channel.havePermission("SendMessage")) ||
isBlocked()
) {
return (
<Base>
<Blocked>

View File

@ -207,7 +207,7 @@ export const UserProfile = observer(
</Button>
</Link>
)}
{(user.relationship === "Friend" || user.bot) && (
{(user.relationship !== "Blocked" && user.relationship !== "BlockedOther" || user.bot) && (
<Localizer>
<Tooltip
content={