diff --git a/src/d2m/actions/register-pk-user.js b/src/d2m/actions/register-pk-user.js index 4946d4f..e68d2cc 100644 --- a/src/d2m/actions/register-pk-user.js +++ b/src/d2m/actions/register-pk-user.js @@ -103,6 +103,7 @@ async function memberToStateContent(pkMessage, author) { // We prefer to use the member's avatar URL data since the image upload can be cached across channels, // unlike the userAvatar URL which is unique per channel, due to the webhook ID being in the URL. const avatar = pkMessage.member.avatar_url || pkMessage.member.webhook_avatar_url || pkMessage.system.avatar_url || file.userAvatar(author) + const color = pkMessage.member.color ?? pkMessage.system.color const content = { displayname: author.username, @@ -110,6 +111,12 @@ async function memberToStateContent(pkMessage, author) { "moe.cadence.ooye.pk_member": pkMessage.member } if (avatar) content.avatar_url = await file.uploadDiscordFileToMxc(avatar) + if (color) { + content["eu.she-a.color"] = { + on_dark: `#${color}`, + on_light: `#${color}` + } + } return content } diff --git a/src/d2m/actions/register-user.js b/src/d2m/actions/register-user.js index d475e54..bd10d5e 100644 --- a/src/d2m/actions/register-user.js +++ b/src/d2m/actions/register-user.js @@ -194,7 +194,9 @@ function memberToPowerLevel(user, member, guild, channel) { * @param {number} powerLevel */ function _hashProfileContent(content, powerLevel) { - const unsignedHash = hasher.h64(`${content.displayname}\u0000${content.avatar_url}\u0000${powerLevel}`) + let toHash = `${content.displayname}\u0000${content.avatar_url}\u0000${powerLevel}` + if (content["eu.she-a.color"]?.on_dark) toHash += `\u0000${content["eu.she-a.color"].on_dark}` + const unsignedHash = hasher.h64(toHash) const signedHash = unsignedHash - 0x8000000000000000n // shifting down to signed 64-bit range return signedHash } @@ -243,6 +245,7 @@ async function syncUser(user, member, channel, guild, roomID, interactionMetadat async function _sendSyncUser(roomID, mxid, content, powerLevel, options) { const currentHash = _hashProfileContent(content, powerLevel ?? 0) const existingHash = select("sim_member", "hashed_profile_content", {room_id: roomID, mxid}).safeIntegers().pluck().get() + console.log(roomID, mxid, existingHash, currentHash) // only do the actual sync if the hash has changed since we last looked const hashHasChanged = existingHash !== currentHash // always okay to add new data. for overwriting, restrict based on options.allowOverwrite, if present diff --git a/src/d2m/converters/message-to-event.js b/src/d2m/converters/message-to-event.js index c0b9622..79c0298 100644 --- a/src/d2m/converters/message-to-event.js +++ b/src/d2m/converters/message-to-event.js @@ -641,8 +641,7 @@ async function messageToEvent(message, guild, options = {}, di) { html = "* " + html } - const flags = message.flags || 0 - if (flags & DiscordTypes.MessageFlags.IsCrosspost) { + if (((message.flags || 0) & DiscordTypes.MessageFlags.IsCrosspost) && message.author?.username) { body = `[↷ ${message.author.username}]\n` + body html = `↷ ${message.author.username}
` + html } diff --git a/src/web/pug/opt-out.pug b/src/web/pug/opt-out.pug index f7233f4..3cb2114 100644 --- a/src/web/pug/opt-out.pug +++ b/src/web/pug/opt-out.pug @@ -16,6 +16,9 @@ block body - let value = !select("opt_out", "user_id", {user_id: session.data.userID}).pluck().get() + noscript + .s-notice.s-notice__danger.mb16 You must enable JavaScript to use this form. Please do that now! + #opt-in-msg(hx-swap-oob="true") if msg .s-notice.s-notice__info.mb16= msg