mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
fix: updateOwner
if there is another owner don't do anything if not then make the next user in the room the owner
This commit is contained in:
@@ -334,14 +334,13 @@ module.exports = function (Messaging) {
|
||||
|
||||
async function updateOwner(roomId) {
|
||||
let nextOwner = await db.getSortedSetRange(`chat:room:${roomId}:owners`, 0, 0);
|
||||
if (!nextOwner[0]) {
|
||||
if (!nextOwner.length) {
|
||||
// no owners left grab next user
|
||||
nextOwner = await db.getSortedSetRange(`chat:room:${roomId}:uids`, 0, 0);
|
||||
}
|
||||
|
||||
const newOwner = nextOwner[0] || 0;
|
||||
if (parseInt(newOwner, 10) > 0) {
|
||||
await db.sortedSetAdd(`chat:room:${roomId}:owners`, Date.now(), newOwner);
|
||||
const newOwner = nextOwner[0] || 0;
|
||||
if (parseInt(newOwner, 10) > 0) {
|
||||
await db.sortedSetAdd(`chat:room:${roomId}:owners`, Date.now(), newOwner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user