mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25: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,16 +334,15 @@ module.exports = function (Messaging) {
|
|||||||
|
|
||||||
async function updateOwner(roomId) {
|
async function updateOwner(roomId) {
|
||||||
let nextOwner = await db.getSortedSetRange(`chat:room:${roomId}:owners`, 0, 0);
|
let nextOwner = await db.getSortedSetRange(`chat:room:${roomId}:owners`, 0, 0);
|
||||||
if (!nextOwner[0]) {
|
if (!nextOwner.length) {
|
||||||
// no owners left grab next user
|
// no owners left grab next user
|
||||||
nextOwner = await db.getSortedSetRange(`chat:room:${roomId}:uids`, 0, 0);
|
nextOwner = await db.getSortedSetRange(`chat:room:${roomId}:uids`, 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
const newOwner = nextOwner[0] || 0;
|
const newOwner = nextOwner[0] || 0;
|
||||||
if (parseInt(newOwner, 10) > 0) {
|
if (parseInt(newOwner, 10) > 0) {
|
||||||
await db.sortedSetAdd(`chat:room:${roomId}:owners`, Date.now(), newOwner);
|
await db.sortedSetAdd(`chat:room:${roomId}:owners`, Date.now(), newOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Messaging.getAllUidsInRoomFromSet = async function (set) {
|
Messaging.getAllUidsInRoomFromSet = async function (set) {
|
||||||
const cacheKey = `${set}:all`;
|
const cacheKey = `${set}:all`;
|
||||||
|
|||||||
Reference in New Issue
Block a user