Task lists WIP:

* dropping role support, does not work.
This commit is contained in:
John Livingston 2024-05-09 18:17:51 +02:00
parent 4f8e11d17d
commit a976b2a1d8
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
4 changed files with 11 additions and 21 deletions

View File

@ -25,8 +25,8 @@ converse.plugins.add('livechat-converse-tasks', {
initOrDestroyChatRoomTaskLists(muc) initOrDestroyChatRoomTaskLists(muc)
}) })
// When the current user role changes, we must also delete or initilize the TaskLists object: // When the current user affiliation changes, we must also delete or initiliaze the TaskLists object:
muc.occupants.on('change:role', occupant => { muc.occupants.on('change:affiliation', occupant => {
if (occupant.get('jid') !== _converse.bare_jid) { // only for myself if (occupant.get('jid') !== _converse.bare_jid) { // only for myself
return return
} }

View File

@ -97,8 +97,8 @@ export function initOrDestroyChatRoomTaskLists (mucModel) {
} }
const myself = mucModel.getOwnOccupant() const myself = mucModel.getOwnOccupant()
if (!myself || !myself.isModerator()) { if (!myself || !['admin', 'owner'].includes(myself.get('affiliation'))) {
// User must be moderator // User must be admin or owner
return _destroyChatRoomTaskLists(mucModel) return _destroyChatRoomTaskLists(mucModel)
} }

View File

@ -4,7 +4,7 @@ This module is a custom module that provide some pubsub services associated to a
This module is entended to be used in the peertube-plugin-livechat project. This module is entended to be used in the peertube-plugin-livechat project.
For each MUC room, there will be an associated pubsub node. For each MUC room, there will be an associated pubsub node.
This node in only accessible by the ROOM moderators. This node in only accessible by the ROOM admin/owner.
This node can contains various objects: This node can contains various objects:
@ -12,7 +12,7 @@ This node can contains various objects:
* tasks * tasks
* ... (more to come) * ... (more to come)
These objects are meant te be shared between moderators. These objects are meant te be shared between admin/owner.
This module is part of peertube-plugin-livechat, and is under the same LICENSE. This module is part of peertube-plugin-livechat, and is under the same LICENSE.

View File

@ -3,10 +3,10 @@
-- but here there are some differences: -- but here there are some differences:
-- * there will be several nodes, using MUC JID+NodeID to access them -- * there will be several nodes, using MUC JID+NodeID to access them
-- (see https://xmpp.org/extensions/xep-0060.html#addressing-jid) -- (see https://xmpp.org/extensions/xep-0060.html#addressing-jid)
-- * nodes can only be subscribed by room moderators, -- * nodes can only be subscribed by room admin/owner,
-- * ... -- * ...
-- Note: all room moderators will have 'publisher' access: -- Note: all room admin/owner will have 'publisher' access:
-- so they can't modify configuration, affiliations or subscriptions. -- so they can't modify configuration, affiliations or subscriptions.
-- There will be no owner. FIXME: is this ok? will prosody accept? (the XEP-0060 says that there must be an owner). -- There will be no owner. FIXME: is this ok? will prosody accept? (the XEP-0060 says that there must be an owner).
@ -226,28 +226,18 @@ function get_mep_service(room_jid, room_host)
get_affiliation = function (jid) get_affiliation = function (jid)
-- module:log("debug", "get_affiliation call for %q", jid); -- module:log("debug", "get_affiliation call for %q", jid);
-- First checking if there is an affiliation on the room for this JID. -- First checking if there is an affiliation on the room for this JID.
local actor_jid = jid_bare(jid); local actor_bare_jid = jid_bare(jid);
local room_affiliation = room:get_affiliation(actor_jid); local room_affiliation = room:get_affiliation(actor_bare_jid);
-- if user is banned, don't go any further -- if user is banned, don't go any further
if (room_affiliation == "outcast") then if (room_affiliation == "outcast") then
-- module:log("debug", "get_affiliation for %q: outcast (existing room affiliation)", jid); -- module:log("debug", "get_affiliation for %q: outcast (existing room affiliation)", jid);
return "outcast"; return "outcast";
end end
if (room_affiliation == "owner" or room_affiliation == "admin") then if (room_affiliation == "owner" or room_affiliation == "admin") then
-- module:log("debug", "get_affiliation for %q: publisher (because owner or admin affiliation)", jid); module:log("debug", "get_affiliation for %q: publisher (because owner or admin affiliation)", jid);
return "publisher"; -- always publisher! (see notes at the beginning of this file) return "publisher"; -- always publisher! (see notes at the beginning of this file)
end end
-- No permanent room affiliation... Checking role (for users currently connected to the room)
local actor_nick = room:get_occupant_jid(jid);
if (actor_nick ~= nil) then
local role = room:get_role(actor_nick);
if valid_roles[role or "none"] >= valid_roles.moderator then
module:log("debug", "get_affiliation for %q: publisher (because of current role)", jid);
return "publisher"; -- always publisher! (see notes at the beginning of this file)
end
end
-- no access! -- no access!
-- module:log("debug", "get_affiliation for %q: outcast", jid); -- module:log("debug", "get_affiliation for %q: outcast", jid);
return "outcast"; return "outcast";