Drop admin permissions correctly
This commit is contained in:
parent
49598c7af7
commit
8c506ed270
2 changed files with 5 additions and 3 deletions
|
@ -197,9 +197,11 @@ async function syncUser(user, member, channel, guild, roomID) {
|
||||||
await api.sendState(roomID, "m.room.member", mxid, content, mxid)
|
await api.sendState(roomID, "m.room.member", mxid, content, mxid)
|
||||||
// Update power levels
|
// Update power levels
|
||||||
const powerLevelsStateContent = await api.getStateEvent(roomID, "m.room.power_levels", "")
|
const powerLevelsStateContent = await api.getStateEvent(roomID, "m.room.power_levels", "")
|
||||||
|
const oldPowerLevel = powerLevelsStateContent.users?.[mxid] || 0
|
||||||
mixin(powerLevelsStateContent, {users: {[mxid]: powerLevel}})
|
mixin(powerLevelsStateContent, {users: {[mxid]: powerLevel}})
|
||||||
if (powerLevel === 0) delete powerLevelsStateContent.users[mxid] // keep the event compact
|
if (powerLevel === 0) delete powerLevelsStateContent.users[mxid] // keep the event compact
|
||||||
await api.sendState(roomID, "m.room.power_levels", "", powerLevelsStateContent)
|
const sendPowerLevelAs = powerLevel < oldPowerLevel ? mxid : undefined // bridge bot won't not have permission to demote equal power users, so do this action as themselves
|
||||||
|
await api.sendState(roomID, "m.room.power_levels", "", powerLevelsStateContent, sendPowerLevelAs)
|
||||||
// Update cached hash
|
// Update cached hash
|
||||||
db.prepare("UPDATE sim_member SET hashed_profile_content = ? WHERE room_id = ? AND mxid = ?").run(currentHash, roomID, mxid)
|
db.prepare("UPDATE sim_member SET hashed_profile_content = ? WHERE room_id = ? AND mxid = ?").run(currentHash, roomID, mxid)
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,10 +103,10 @@ function isWebhookMessage(message) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ephemeral messages can be generated if a slash command is attached to the same bot that OOYE is running on
|
* Ephemeral messages can be generated if a slash command is attached to the same bot that OOYE is running on
|
||||||
* @param {DiscordTypes.APIMessage} message
|
* @param {Pick<DiscordTypes.APIMessage, "flags">} message
|
||||||
*/
|
*/
|
||||||
function isEphemeralMessage(message) {
|
function isEphemeralMessage(message) {
|
||||||
return message.flags & (1 << 6);
|
return message.flags && (message.flags & (1 << 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} snowflake */
|
/** @param {string} snowflake */
|
||||||
|
|
Loading…
Reference in a new issue