Set sim power a little bit better

I should probably change this to use kstate.
This commit is contained in:
Cadence Ember 2024-03-15 15:52:20 +13:00
parent 08c01e8664
commit 955310b759

View file

@ -198,7 +198,8 @@ async function syncUser(user, member, channel, guild, roomID) {
// Update power levels
const powerLevelsStateContent = await api.getStateEvent(roomID, "m.room.power_levels", "")
mixin(powerLevelsStateContent, {users: {[mxid]: powerLevel}})
api.sendState(roomID, "m.room.power_levels", "", powerLevelsStateContent)
if (powerLevel === 0) delete powerLevelsStateContent.users[mxid] // keep the event compact
await api.sendState(roomID, "m.room.power_levels", "", powerLevelsStateContent)
// Update cached hash
db.prepare("UPDATE sim_member SET hashed_profile_content = ? WHERE room_id = ? AND mxid = ?").run(currentHash, roomID, mxid)
}