mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-08 01:45:28 +00:00
invite embeds preview
This commit is contained in:
@@ -24,6 +24,7 @@ import MessageBase, {
|
||||
import Attachment from "./attachments/Attachment";
|
||||
import { MessageReply } from "./attachments/MessageReply";
|
||||
import Embed from "./embed/Embed";
|
||||
import EmbedInvite from "./embed/EmbedInvite";
|
||||
|
||||
interface Props {
|
||||
attachContext?: boolean;
|
||||
@@ -36,6 +37,7 @@ interface Props {
|
||||
hideReply?: boolean;
|
||||
}
|
||||
|
||||
|
||||
const Message = observer(
|
||||
({
|
||||
highlight,
|
||||
@@ -142,6 +144,22 @@ const Message = observer(
|
||||
</span>
|
||||
)}
|
||||
{replacement ?? <Markdown content={content} />}
|
||||
{(() => {
|
||||
if (content.includes(".revolt.chat/invite/") || content.includes("rvlt.gg/")) {
|
||||
const inviteRegex = /(?:(?:app|nightly)\.revolt\.chat\/invite|rvlt.gg)\/([A-Za-z0-9]*)/g;
|
||||
if (inviteRegex.test(content)) {
|
||||
let results = [];
|
||||
let match;
|
||||
inviteRegex.lastIndex = 0;
|
||||
while ((match = inviteRegex.exec(content)) !== null) {
|
||||
if (!results.includes(match[1])) {
|
||||
results.push(match[1]);
|
||||
}
|
||||
}
|
||||
return results.map(code => <EmbedInvite code={code} />);
|
||||
}
|
||||
}
|
||||
})()}
|
||||
{queued?.error && (
|
||||
<Overline type="error" error={queued.error} />
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user