changing spaces to tabs
This commit is contained in:
parent
c22f434c1f
commit
c8021cadec
9 changed files with 154 additions and 120 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,2 +1,5 @@
|
|||
{
|
||||
"editor.insertSpaces": false,
|
||||
"editor.detectIndentation": false,
|
||||
"editor.tabSize": 3
|
||||
}
|
||||
|
|
|
@ -90,6 +90,16 @@ function getAllState(roomID) {
|
|||
return mreq.mreq("GET", `/client/v3/rooms/${roomID}/state`)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} roomID
|
||||
* @param {string} type
|
||||
* @param {string} key
|
||||
* @returns the *content* of the state event
|
||||
*/
|
||||
function getStateEvent(roomID, type, key) {
|
||||
return mreq.mreq("GET", `/client/v3/rooms/${roomID}/state/${type}/${key}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* "Any of the AS's users must be in the room. This API is primarily for Application Services and should be faster to respond than /members as it can be implemented more efficiently on the server."
|
||||
* @param {string} roomID
|
||||
|
@ -150,6 +160,26 @@ async function profileSetAvatarUrl(mxid, avatar_url) {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a user's power level within a room.
|
||||
* @param {string} roomID
|
||||
* @param {string} mxid
|
||||
* @param {number} power
|
||||
*/
|
||||
async function setUserPower(roomID, mxid, power) {
|
||||
// Yes it's this hard https://github.com/matrix-org/matrix-appservice-bridge/blob/2334b0bae28a285a767fe7244dad59f5a5963037/src/components/intent.ts#L352
|
||||
const powerLevels = await getStateEvent(roomID, "m.room.power_levels", "")
|
||||
const users = powerLevels.users || {}
|
||||
if (power != null) {
|
||||
users[mxid] = power
|
||||
} else {
|
||||
delete users[mxid]
|
||||
}
|
||||
powerLevels.users = users
|
||||
await sendState(roomID, "m.room.power_levels", "", powerLevels)
|
||||
return powerLevels
|
||||
}
|
||||
|
||||
module.exports.path = path
|
||||
module.exports.register = register
|
||||
module.exports.createRoom = createRoom
|
||||
|
@ -164,3 +194,4 @@ module.exports.sendEvent = sendEvent
|
|||
module.exports.redactEvent = redactEvent
|
||||
module.exports.profileSetDisplayname = profileSetDisplayname
|
||||
module.exports.profileSetAvatarUrl = profileSetAvatarUrl
|
||||
module.exports.setUserPower = setUserPower
|
||||
|
|
Loading…
Reference in a new issue