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

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

View file

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

View file

@ -39,6 +39,7 @@ type UsernameProps = Omit<
masquerade?: API.Masquerade;
showServerIdentity?: boolean | "both";
override?: string;
innerRef?: Ref<any>;
};
@ -64,13 +65,16 @@ export const Username = observer(
masquerade,
showServerIdentity,
innerRef,
override,
...otherProps
}: UsernameProps) => {
let username = user?.username;
let color = masquerade?.colour;
let timed_out: Date | undefined;
if (user && showServerIdentity) {
if (override) {
username = override;
} else if (user && showServerIdentity) {
const { server } = useParams<{ server?: string }>();
if (server) {
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;
},
);