Update global profiles for sims

This commit is contained in:
Cadence Ember
2025-12-01 16:53:09 +13:00
parent 493bc25602
commit c7313035a4
4 changed files with 85 additions and 31 deletions
+2 -9
View File
@@ -128,16 +128,9 @@ async function syncUser(author, roomID, shouldActuallySync) {
const mxid = await ensureSimJoined(fakeUserID, author, roomID)
if (shouldActuallySync) {
// Build current profile data
// Build current profile data and sync if the hash has changed
const content = await authorToStateContent(author)
const currentHash = registerUser._hashProfileContent(content, 0)
const existingHash = select("sim_member", "hashed_profile_content", {room_id: roomID, mxid}).safeIntegers().pluck().get()
// Only do the actual sync if the hash has changed since we last looked
if (existingHash !== currentHash) {
await api.sendState(roomID, "m.room.member", mxid, content, mxid)
db.prepare("UPDATE sim_member SET hashed_profile_content = ? WHERE room_id = ? AND mxid = ?").run(currentHash, roomID, mxid)
}
await registerUser._sendSyncUser(roomID, mxid, content, null)
}
return mxid