From 818311bcb4cbca013e66c71c5c0cb7b410b994b0 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 28 Aug 2024 01:35:53 +1200 Subject: [PATCH] Use kstate $url feature for channel icons --- d2m/actions/create-room.js | 3 +-- d2m/actions/create-space.js | 1 - d2m/actions/create-space.test.js | 1 - test/data.js | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/d2m/actions/create-room.js b/d2m/actions/create-room.js index 322f8be..2dd62e0 100644 --- a/d2m/actions/create-room.js +++ b/d2m/actions/create-room.js @@ -120,8 +120,7 @@ async function channelToKState(channel, guild) { if (customAvatar) { avatarEventContent.url = customAvatar } else if (guild.icon) { - avatarEventContent.discord_path = file.guildIcon(guild) - avatarEventContent.url = await file.uploadDiscordFileToMxc(avatarEventContent.discord_path) // TODO: somehow represent future values in kstate (callbacks?), while still allowing for diffing, so test cases don't need to touch the media API + avatarEventContent.url = {$url: file.guildIcon(guild)} } let history_visibility = PRIVACY_ENUMS.ROOM_HISTORY_VISIBILITY[privacyLevel] diff --git a/d2m/actions/create-space.js b/d2m/actions/create-space.js index b15cba6..a9b8448 100644 --- a/d2m/actions/create-space.js +++ b/d2m/actions/create-space.js @@ -65,7 +65,6 @@ async function guildToKState(guild, privacyLevel) { "m.room.name/": {name: guild.name}, "m.room.avatar/": { $if: guild.icon, - discord_path: file.guildIcon(guild), url: {$url: file.guildIcon(guild)} }, "m.room.guest_access/": {guest_access: createRoom.PRIVACY_ENUMS.GUEST_ACCESS[privacyLevel]}, diff --git a/d2m/actions/create-space.test.js b/d2m/actions/create-space.test.js index b1c1f06..c4111db 100644 --- a/d2m/actions/create-space.test.js +++ b/d2m/actions/create-space.test.js @@ -14,7 +14,6 @@ test("guild2space: can generate kstate for a guild, passing privacy level 0", as await kstateUploadMxc(kstateStripConditionals(await guildToKState(testData.guild.general, 0))), { "m.room.avatar/": { - discord_path: "/icons/112760669178241024/a_f83622e09ead74f0c5c527fe241f8f8c.png?size=1024", url: "mxc://cadence.moe/zKXGZhmImMHuGQZWJEFKJbsF" }, "m.room.guest_access/": { diff --git a/test/data.js b/test/data.js index 771c183..456033a 100644 --- a/test/data.js +++ b/test/data.js @@ -38,8 +38,7 @@ module.exports = { }] }, "m.room.avatar/": { - discord_path: "/icons/112760669178241024/a_f83622e09ead74f0c5c527fe241f8f8c.png?size=1024", - url: "mxc://cadence.moe/zKXGZhmImMHuGQZWJEFKJbsF" + url: {$url: "/icons/112760669178241024/a_f83622e09ead74f0c5c527fe241f8f8c.png?size=1024"} }, "m.room.power_levels/": { events: {