Compare commits

..

No commits in common. "b3ef973568cd6bee817a8bc6368160bb39e7784b" and "db2c038f408ca75914711e80d6e8ba434daa07f7" have entirely different histories.

4 changed files with 3 additions and 15 deletions

View file

@ -103,7 +103,6 @@ async function memberToStateContent(pkMessage, author) {
// We prefer to use the member's avatar URL data since the image upload can be cached across channels, // 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. // 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 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 = { const content = {
displayname: author.username, displayname: author.username,
@ -111,12 +110,6 @@ async function memberToStateContent(pkMessage, author) {
"moe.cadence.ooye.pk_member": pkMessage.member "moe.cadence.ooye.pk_member": pkMessage.member
} }
if (avatar) content.avatar_url = await file.uploadDiscordFileToMxc(avatar) if (avatar) content.avatar_url = await file.uploadDiscordFileToMxc(avatar)
if (color) {
content["eu.she-a.color"] = {
on_dark: `#${color}`,
on_light: `#${color}`
}
}
return content return content
} }

View file

@ -194,9 +194,7 @@ function memberToPowerLevel(user, member, guild, channel) {
* @param {number} powerLevel * @param {number} powerLevel
*/ */
function _hashProfileContent(content, powerLevel) { function _hashProfileContent(content, powerLevel) {
let toHash = `${content.displayname}\u0000${content.avatar_url}\u0000${powerLevel}` const unsignedHash = hasher.h64(`${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 const signedHash = unsignedHash - 0x8000000000000000n // shifting down to signed 64-bit range
return signedHash return signedHash
} }
@ -245,7 +243,6 @@ async function syncUser(user, member, channel, guild, roomID, interactionMetadat
async function _sendSyncUser(roomID, mxid, content, powerLevel, options) { async function _sendSyncUser(roomID, mxid, content, powerLevel, options) {
const currentHash = _hashProfileContent(content, powerLevel ?? 0) const currentHash = _hashProfileContent(content, powerLevel ?? 0)
const existingHash = select("sim_member", "hashed_profile_content", {room_id: roomID, mxid}).safeIntegers().pluck().get() 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 // only do the actual sync if the hash has changed since we last looked
const hashHasChanged = existingHash !== currentHash const hashHasChanged = existingHash !== currentHash
// always okay to add new data. for overwriting, restrict based on options.allowOverwrite, if present // always okay to add new data. for overwriting, restrict based on options.allowOverwrite, if present

View file

@ -641,7 +641,8 @@ async function messageToEvent(message, guild, options = {}, di) {
html = "* " + html html = "* " + html
} }
if (((message.flags || 0) & DiscordTypes.MessageFlags.IsCrosspost) && message.author?.username) { const flags = message.flags || 0
if (flags & DiscordTypes.MessageFlags.IsCrosspost) {
body = `[↷ ${message.author.username}]\n` + body body = `[↷ ${message.author.username}]\n` + body
html = `↷ <strong>${message.author.username}</strong><br>` + html html = `↷ <strong>${message.author.username}</strong><br>` + html
} }

View file

@ -16,9 +16,6 @@ block body
- let value = !select("opt_out", "user_id", {user_id: session.data.userID}).pluck().get() - 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") #opt-in-msg(hx-swap-oob="true")
if msg if msg
.s-notice.s-notice__info.mb16= msg .s-notice.s-notice__info.mb16= msg