fix: updateOwner

if there is another owner don't do anything
if not then make the next user in the room the owner
isekai-main
Barış Soner Uşaklı 2 years ago
parent 91642cb324
commit 16fe1eb98c

@ -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);
}
}
}

Loading…
Cancel
Save