Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider cc141d39 rédigé par Sorunome's avatar Sorunome
Parcourir les fichiers

Merge branch 'soru/inlineimages' into develop

parents b42fa784 9c1f83c5
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -190,7 +190,9 @@ export class MatrixMessageProcessor { ...@@ -190,7 +190,9 @@ export class MatrixMessageProcessor {
} }
if (!emoji) { if (!emoji) {
return await this.escapeDiscord(name); const content = await this.escapeDiscord(name);
const url = this.params && this.params.mxClient ? this.params.mxClient.mxcUrlToHttp(attrs.src) : attrs.src;
return attrs.src ? `[${content}](${url})` : content;
} }
return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`; return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}>`;
} }
......
...@@ -334,14 +334,14 @@ code ...@@ -334,14 +334,14 @@ code
const result = await mp.FormatMessage(msg, guild as any); const result = await mp.FormatMessage(msg, guild as any);
expect(result).is.equal("<:test_emoji:123456>"); expect(result).is.equal("<:test_emoji:123456>");
}); });
it("ignores unknown mxc urls", async () => { it("parses unknown mxc urls", async () => {
const mp = new MatrixMessageProcessor(bot); const mp = new MatrixMessageProcessor(bot);
const guild = new MockGuild("1234"); const guild = new MockGuild("1234");
const emoji = new MockEmoji("123456", "test_emoji"); const emoji = new MockEmoji("123456", "test_emoji");
guild.emojis.set("123456", emoji); guild.emojis.set("123456", emoji);
const msg = getHtmlMessage("<img alt=\"yay\" src=\"mxc://unreal_emote:localhost\">"); const msg = getHtmlMessage("<img alt=\"yay\" src=\"mxc://unreal_emote:localhost\">");
const result = await mp.FormatMessage(msg, guild as any); const result = await mp.FormatMessage(msg, guild as any);
expect(result).is.equal("yay"); expect(result).is.equal("[yay](mxc://unreal_emote:localhost)");
}); });
it("ignores with no alt / title, too", async () => { it("ignores with no alt / title, too", async () => {
const mp = new MatrixMessageProcessor(bot); const mp = new MatrixMessageProcessor(bot);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter