From d91cbb9e2582d54dea9d1b78c79c1116d04de373 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Sun, 5 May 2024 23:14:06 +0200 Subject: [PATCH] Task lists WIP: * aborted attempt to auto create the first task list --- .../mod_pubsub_peertubelivechat.lua | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua b/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua index f12a9214..0e520db4 100644 --- a/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua +++ b/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua @@ -23,10 +23,13 @@ local cache = require "util.cache"; local st = require "util.stanza"; local new_id = require "util.id".medium; local storagemanager = require "core.storagemanager"; +local uuid_generate = require "util.uuid".generate; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; +local xmlns_tasklist = "urn:peertube-plugin-livechat:tasklist"; +local xmlns_task = "urn:peertube-plugin-livechat:task" local lib_pubsub = module:require "pubsub"; @@ -297,6 +300,29 @@ end module:hook("iq/bare/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); module:hook("iq/bare/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); -- FIXME: should not be necessary, as we don't have owners. +-- FIXME: this code does not work, don't know why +-- -- When a livechat-tasks node is created, we create a first task list with the same name as the room. +-- module:hook("node-created", function (event) +-- local node = event.node; +-- local service = event.service; + +-- if (node ~= 'livechat-tasks') then +-- return +-- end + +-- module:log("debug", "New node %q created, we must create the first tasklist", node); + +-- local id = uuid_generate(); +-- local stanza = st.stanza("iq", {}); -- this stanza is only here to construct and get a child item. +-- stanza:tag("item", {}) +-- :tag("tasklist", { xmlns = xmlns_tasklist }) +-- :tag("name"):text(room.get_name()):up(); + +-- local item = stanza:get_child("item"); + +-- service:publish('livechat-tasks', true, id, item); -- true as second parameters: no actor, force rights. +-- end); + -- Destroying the node when the room is destroyed -- FIXME: really? as the room will be automatically recreated in some cases... module:hook("muc-room-destroyed", function(event) @@ -308,6 +334,8 @@ module:hook("muc-room-destroyed", function(event) local service = services[room_jid]; if service then + module:log("debug", "Deleting nodes for room %q", room_jid); + for node in pairs(service.nodes) do service:delete(node, true); end local item = mep_service_items[room_jid];