From cd195f92e0e7acc3685447d79c35a42ae0963071 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 20 Sep 2023 16:12:19 +1200 Subject: [PATCH] rename a function --- d2m/actions/register-user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/d2m/actions/register-user.js b/d2m/actions/register-user.js index a23513e..64e0ceb 100644 --- a/d2m/actions/register-user.js +++ b/d2m/actions/register-user.js @@ -119,7 +119,7 @@ async function memberToStateContent(user, member, guildID) { return content } -function calculateProfileEventContentHash(content) { +function hashProfileContent(content) { return `${content.displayname}\u0000${content.avatar_url}` } @@ -136,12 +136,12 @@ function calculateProfileEventContentHash(content) { async function syncUser(user, member, guildID, roomID) { const mxid = await ensureSimJoined(user, roomID) const content = await memberToStateContent(user, member, guildID) - const profileEventContentHash = calculateProfileEventContentHash(content) + const currentHash = hashProfileContent(content) const existingHash = select("sim_member", "profile_event_content_hash", "WHERE room_id = ? AND mxid = ?").pluck().get(roomID, mxid) // only do the actual sync if the hash has changed since we last looked - if (existingHash !== profileEventContentHash) { + if (existingHash !== currentHash) { await api.sendState(roomID, "m.room.member", mxid, content, mxid) - db.prepare("UPDATE sim_member SET profile_event_content_hash = ? WHERE room_id = ? AND mxid = ?").run(profileEventContentHash, roomID, mxid) + db.prepare("UPDATE sim_member SET profile_event_content_hash = ? WHERE room_id = ? AND mxid = ?").run(currentHash, roomID, mxid) } return mxid }