From 5d1212fa671ada4b41b6aa0ff9d5d79d6b124a75 Mon Sep 17 00:00:00 2001 From: Declan Chidlow Date: Fri, 30 Aug 2024 15:55:56 +0800 Subject: [PATCH] Allow DMing non friends --- .../common/messaging/MessageBox.tsx | 22 +++++++++++++++++-- .../modals/components/legacy/UserProfile.tsx | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/common/messaging/MessageBox.tsx b/src/components/common/messaging/MessageBox.tsx index 78c26981..35bd6bab 100644 --- a/src/components/common/messaging/MessageBox.tsx +++ b/src/components/common/messaging/MessageBox.tsx @@ -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 ( @@ -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 ( diff --git a/src/controllers/modals/components/legacy/UserProfile.tsx b/src/controllers/modals/components/legacy/UserProfile.tsx index dd73d897..6a7ea939 100644 --- a/src/controllers/modals/components/legacy/UserProfile.tsx +++ b/src/controllers/modals/components/legacy/UserProfile.tsx @@ -207,7 +207,7 @@ export const UserProfile = observer( )} - {(user.relationship === "Friend" || user.bot) && ( + {(user.relationship !== "Blocked" && user.relationship !== "BlockedOther" || user.bot) && (