feat: allow multiple room owners, closes #6503
parent
4b92df75df
commit
91642cb324
@ -0,0 +1,34 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
const db = require('../../database');
|
||||||
|
const batch = require('../../batch');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Create chat:room:<room_id>:owners zset',
|
||||||
|
timestamp: Date.UTC(2023, 6, 17),
|
||||||
|
method: async function () {
|
||||||
|
const { progress } = this;
|
||||||
|
|
||||||
|
progress.total = await db.sortedSetCard('chat:rooms');
|
||||||
|
|
||||||
|
await batch.processSortedSet('chat:rooms', async (roomIds) => {
|
||||||
|
progress.incr(roomIds.length);
|
||||||
|
const roomData = await db.getObjects(
|
||||||
|
roomIds.map(id => `chat:room:${id}`)
|
||||||
|
);
|
||||||
|
|
||||||
|
const bulkAdd = [];
|
||||||
|
roomData.forEach((room) => {
|
||||||
|
if (room && room.roomId && room.owner) {
|
||||||
|
bulkAdd.push([`chat:room:${room.roomId}:owners`, room.timestamp, room.owner]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await db.sortedSetAddBulk(bulkAdd);
|
||||||
|
}, {
|
||||||
|
batch: 500,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
@ -1,12 +1,17 @@
|
|||||||
{{{ each users }}}
|
{{{ each users }}}
|
||||||
<li class="list-group-item d-flex align-items-center justify-content-between" data-index="{./index}">
|
<li class="list-group-item d-flex align-items-center justify-content-between" data-uid="{./uid}" data-index="{./index}">
|
||||||
<div class="d-flex gap-1 align-items-center">
|
<div class="d-flex gap-1 align-items-center">
|
||||||
{buildAvatar(users, "24px", true)}
|
{buildAvatar(users, "24px", true)}
|
||||||
<span>{./username}{{{ if ./isOwner }}} <i class="fa fa-star text-warning" title="[[modules:chat.owner]]"></i>{{{ end }}}</span>
|
<span>{./username} <i component="chat/manage/user/owner/icon" class="fa fa-star text-warning {{{ if !./isOwner }}}hidden{{{ end }}}" title="[[modules:chat.owner]]" data-bs-toggle="tooltip"></i></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="d-flex gap-1">
|
||||||
|
{{{ if ./canToggleOwner }}}
|
||||||
|
<button class="btn btn-sm btn-light" data-bs-toggle="tooltip" data-action="toggleOwner" data-uid="{./uid}" title="[[modules:chat.grant-rescind-ownership]]"><i class="fa fa-star text-warning"></i></button>
|
||||||
|
{{{ end }}}
|
||||||
|
|
||||||
{{{ if ./canKick }}}
|
{{{ if ./canKick }}}
|
||||||
<button class="btn btn-sm btn-link" data-action="kick" data-uid="{./uid}">[[modules:chat.kick]]</button>
|
<button class="btn btn-sm btn-light" data-action="kick" data-uid="{./uid}" data-bs-toggle="tooltip" title="[[modules:chat.kick]]"><i class="fa fa-ban text-danger"></i></button>
|
||||||
{{{ end }}}
|
{{{ end }}}
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{{{ end }}}
|
{{{ end }}}
|
Loading…
Reference in New Issue