feat: add support for webhooks

fix: removing reactions crashes client
This commit is contained in:
Paul Makles 2023-06-03 19:29:14 +01:00
parent 00708bb8f4
commit 1862db89a3
No known key found for this signature in database
GPG key ID: 5059F398521BB0F6
6 changed files with 31 additions and 5 deletions

3
.env
View file

@ -1,2 +1,3 @@
VITE_API_URL=https://api.revolt.chat # VITE_API_URL=https://api.revolt.chat
VITE_API_URL=https://revolt.chat/api
VITE_THEMES_URL=https://themes.revolt.chat VITE_THEMES_URL=https://themes.revolt.chat

2
external/lang vendored

@ -1 +1 @@
Subproject commit e0244eb1c416a01f3c652ab0a2e99832df9b53c4 Subproject commit 1c99677d4f9319d7b380d525a4ca25e57a3d8730

2
external/revolt.js vendored

@ -1 +1 @@
Subproject commit 29df60f782652111d1dfd5480a8e84e73643fdc8 Subproject commit 1e45043151550187f0b2cb46cab4e8c5f4b087e0

View file

@ -33,7 +33,7 @@ import InviteList from "./embed/EmbedInvite";
interface Props { interface Props {
attachContext?: boolean; attachContext?: boolean;
queued?: QueuedMessage; queued?: QueuedMessage;
message: MessageObject; message: MessageObject & { webhook: { name: string; avatar?: string } };
highlight?: boolean; highlight?: boolean;
contrast?: boolean; contrast?: boolean;
content?: Children; content?: Children;
@ -138,6 +138,11 @@ const Message = observer(
<UserIcon <UserIcon
className="avatar" className="avatar"
url={message.generateMasqAvatarURL()} url={message.generateMasqAvatarURL()}
override={
message.webhook?.avatar
? `https://autumn.revolt.chat/avatars/${message.webhook.avatar}`
: undefined
}
target={user} target={user}
size={36} size={36}
onClick={handleUserClick} onClick={handleUserClick}
@ -158,6 +163,7 @@ const Message = observer(
showServerIdentity showServerIdentity
onClick={handleUserClick} onClick={handleUserClick}
masquerade={message.masquerade!} masquerade={message.masquerade!}
override={message.webhook?.name}
{...userContext} {...userContext}
/> />
<MessageDetail <MessageDetail

View file

@ -14,6 +14,7 @@ import IconBase, { IconBaseProps } from "../IconBase";
type VoiceStatus = "muted" | "deaf"; type VoiceStatus = "muted" | "deaf";
interface Props extends IconBaseProps<User> { interface Props extends IconBaseProps<User> {
status?: boolean; status?: boolean;
override?: string;
voice?: VoiceStatus; voice?: VoiceStatus;
masquerade?: API.Masquerade; masquerade?: API.Masquerade;
showServerIdentity?: boolean; showServerIdentity?: boolean;
@ -70,12 +71,15 @@ export default observer(
showServerIdentity, showServerIdentity,
masquerade, masquerade,
innerRef, innerRef,
override,
...svgProps ...svgProps
} = props; } = props;
let { url } = props; let { url } = props;
if (masquerade?.avatar) { if (masquerade?.avatar) {
url = client.proxyFile(masquerade.avatar); url = client.proxyFile(masquerade.avatar);
} else if (override) {
url = override;
} else if (!url) { } else if (!url) {
let override; let override;
if (target && showServerIdentity) { if (target && showServerIdentity) {

View file

@ -39,6 +39,7 @@ type UsernameProps = Omit<
masquerade?: API.Masquerade; masquerade?: API.Masquerade;
showServerIdentity?: boolean | "both"; showServerIdentity?: boolean | "both";
override?: string;
innerRef?: Ref<any>; innerRef?: Ref<any>;
}; };
@ -64,13 +65,16 @@ export const Username = observer(
masquerade, masquerade,
showServerIdentity, showServerIdentity,
innerRef, innerRef,
override,
...otherProps ...otherProps
}: UsernameProps) => { }: UsernameProps) => {
let username = user?.username; let username = user?.username;
let color = masquerade?.colour; let color = masquerade?.colour;
let timed_out: Date | undefined; let timed_out: Date | undefined;
if (user && showServerIdentity) { if (override) {
username = override;
} else if (user && showServerIdentity) {
const { server } = useParams<{ server?: string }>(); const { server } = useParams<{ server?: string }>();
if (server) { if (server) {
const client = useClient(); const client = useClient();
@ -146,6 +150,17 @@ export const Username = observer(
); );
} }
if (override) {
return (
<>
{el}
<BotBadge>
<Text id="app.main.channel.bot" />
</BotBadge>
</>
);
}
return el; return el;
}, },
); );