diff --git a/CHANGELOG.md b/CHANGELOG.md
index 36121b9e..8dd5ac07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
TODO: add documentation link for the task-list in the CHANGELOG.
+TODO: tag custom ConverseJS, and update build-conversejs.sh.
## ??? (Not Released Yet)
diff --git a/conversejs/build-conversejs.sh b/conversejs/build-conversejs.sh
index cdb005e2..9b6b5673 100644
--- a/conversejs/build-conversejs.sh
+++ b/conversejs/build-conversejs.sh
@@ -14,7 +14,7 @@ set -x
CONVERSE_VERSION="v10.1.6"
CONVERSE_REPO="https://github.com/conversejs/converse.js.git"
# You can eventually set CONVERSE_COMMIT to a specific commit ID, if you want to apply some patches.
-CONVERSE_COMMIT=""
+CONVERSE_COMMIT="821b41e189b25316b9a044cb41ecc9b3f1910172"
# 2014-01-16: we are using a custom version, to wait for some PR to be apply upstream.
# This version includes following changes:
diff --git a/conversejs/custom/plugins/tasks/constants.js b/conversejs/custom/plugins/tasks/constants.js
new file mode 100644
index 00000000..3bf738ad
--- /dev/null
+++ b/conversejs/custom/plugins/tasks/constants.js
@@ -0,0 +1 @@
+export const XMLNS_TASKLIST = 'https://livingston.frama.io/peertube-plugin-livechat/protocol/tasklist'
diff --git a/conversejs/custom/plugins/tasks/muc-task-lists-view.js b/conversejs/custom/plugins/tasks/muc-task-lists-view.js
index 0dc5de9c..cb491a29 100644
--- a/conversejs/custom/plugins/tasks/muc-task-lists-view.js
+++ b/conversejs/custom/plugins/tasks/muc-task-lists-view.js
@@ -1,11 +1,14 @@
import { CustomElement } from 'shared/components/element.js'
import { api } from '@converse/headless/core'
import tplMucTaskLists from './templates/muc-task-lists'
+import { __ } from 'i18n'
export default class MUCTaskListsView extends CustomElement {
static get properties () {
return {
- model: { type: Object, attribute: true }
+ model: { type: Object, attribute: true },
+ new_task_list_name: { type: String, attribute: false },
+ create_tasklist_error_message: { type: String, attribute: false }
}
}
@@ -20,7 +23,29 @@ export default class MUCTaskListsView extends CustomElement {
}
render () {
- return tplMucTaskLists(this.model)
+ return tplMucTaskLists(this, this.model)
+ }
+
+ async submitCreateTaskList (ev) {
+ ev.preventDefault()
+ const name = ev.target.name.value.trim()
+ if (this.create_tasklist_error_message) {
+ this.create_tasklist_error_message = ''
+ }
+
+ if ((name ?? '') === '') { return }
+
+ try {
+ await this.model.createTaskList({
+ name
+ })
+
+ this.new_task_list_name = ''
+ } catch (err) {
+ console.error(err)
+ // eslint-disable-next-line no-undef
+ this.create_tasklist_error_message = __(LOC_task_list_create_error)
+ }
}
}
diff --git a/conversejs/custom/plugins/tasks/task-lists.js b/conversejs/custom/plugins/tasks/task-lists.js
index 5c0ef1fa..09bafb62 100644
--- a/conversejs/custom/plugins/tasks/task-lists.js
+++ b/conversejs/custom/plugins/tasks/task-lists.js
@@ -1,7 +1,10 @@
import { Collection } from '@converse/skeletor/src/collection.js'
import { ChatRoomTaskList } from './task-list'
+import { XMLNS_TASKLIST } from './constants'
import { initStorage } from '@converse/headless/utils/storage.js'
import { getUniqueId } from '@converse/headless/utils/core.js'
+import { converse, api } from '@converse/headless/core'
+const { $build } = converse.env
/**
* A list of {@link _converse.ChatRoomTaskList} instances, representing task lists associated to a MUC.
@@ -75,6 +78,15 @@ class ChatRoomTaskLists extends Collection {
})
}
}
+
+ async createTaskList (data) {
+ const name = data?.name
+ if (!name) { throw new Error('Missing name') }
+
+ const item = $build('item').c('tasklist', { xmlns: XMLNS_TASKLIST })
+ item.c('name').t(name)
+ await api.pubsub.publish(this.chatroom.get('jid'), 'livechat-tasks', item)
+ }
}
export {
diff --git a/conversejs/custom/plugins/tasks/templates/muc-task-lists.js b/conversejs/custom/plugins/tasks/templates/muc-task-lists.js
index 178fc604..12a796e8 100644
--- a/conversejs/custom/plugins/tasks/templates/muc-task-lists.js
+++ b/conversejs/custom/plugins/tasks/templates/muc-task-lists.js
@@ -2,7 +2,7 @@ import { html } from 'lit'
import { repeat } from 'lit/directives/repeat.js'
import { __ } from 'i18n'
-export default function tplMucTaskLists (tasklists) {
+export default function tplMucTaskLists (el, tasklists) {
if (!tasklists) { // if user losed rights
return html`` // FIXME: add a message like "you dont have access"?
}
@@ -14,24 +14,17 @@ export default function tplMucTaskLists (tasklists) {
const i18nTaskListName = __(LOC_task_list_name)
return html`
-
diff --git a/conversejs/custom/plugins/tasks/utils.js b/conversejs/custom/plugins/tasks/utils.js
index 1e1664bd..cf2448a3 100644
--- a/conversejs/custom/plugins/tasks/utils.js
+++ b/conversejs/custom/plugins/tasks/utils.js
@@ -1,5 +1,6 @@
import { converse, _converse, api } from '../../../src/headless/core.js'
import { __ } from 'i18n'
+const { Strophe, $iq } = converse.env
export function getHeadingButtons (view, buttons) {
const muc = view.model
@@ -38,6 +39,32 @@ function _initChatRoomTaskLists (mucModel) {
mucModel.tasklists = new _converse.ChatRoomTaskLists(undefined, { chatroom: mucModel })
mucModel.tasks = new _converse.ChatRoomTasks(undefined, { chatroom: mucModel })
+
+ // Requesting all items.
+ const stanza = $iq({
+ type: 'get',
+ from: _converse.bare_jid,
+ to: mucModel.get('jid')
+ }).c('pubsub', { xmlns: Strophe.NS.PUBSUB })
+ .c('items', { node: 'livechat-tasks' })
+
+ api.sendIQ(stanza).then(
+ (iq) => {
+ console.debug('task lists: ', iq)
+ },
+ (iq) => {
+ if (iq === null || !iq?.querySelector) {
+ console.error('Failed to retrieve tasks', iq)
+ return
+ }
+ if (!iq.querySelector('error[type="cancel"] item-not-found')) {
+ console.error('Failed to retrieve tasks:', iq)
+ return
+ }
+ // This is totally normal when you open an empty task list.
+ console.log('Not livechat-tasks node for now')
+ }
+ )
}
function _destroyChatRoomTaskLists (mucModel) {
@@ -55,7 +82,7 @@ export function initOrDestroyChatRoomTaskLists (mucModel) {
}
if (mucModel.session.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
- _destroyChatRoomTaskLists(mucModel)
+ return _destroyChatRoomTaskLists(mucModel)
}
const myself = mucModel.getOwnOccupant()
diff --git a/conversejs/loc.keys.js b/conversejs/loc.keys.js
index f51e7472..ad6c6cc8 100644
--- a/conversejs/loc.keys.js
+++ b/conversejs/loc.keys.js
@@ -18,6 +18,7 @@ const locKeys = [
'login_external_auth_alert_message',
'tasks',
'task_list_create',
+ 'task_list_create_error',
'task_list_name'
]
diff --git a/languages/en.yml b/languages/en.yml
index 3baf26dc..55a2a5bf 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -437,4 +437,5 @@ login_external_auth_alert_message: "Authentication failed"
tasks: 'Tasks'
task_list_create: 'Create new task list:'
+task_list_create_error: 'Error when saving the task list'
task_list_name: 'Task list name'
\ No newline at end of file
diff --git a/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua b/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua
index 419ad65c..a86d4308 100644
--- a/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua
+++ b/prosody-modules/mod_pubsub_peertubelivechat/mod_pubsub_peertubelivechat.lua
@@ -18,6 +18,8 @@ local jid_bare = require "util.jid".bare;
local jid_split = require "util.jid".split;
local jid_join = require "util.jid".join;
local cache = require "util.cache";
+local st = require "util.stanza";
+local new_id = require "util.id".medium;
local storagemanager = require "core.storagemanager";
local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
@@ -225,8 +227,8 @@ function get_mep_service(room_jid, room_host)
};
max_items = max_max_items;
- autocreate_on_publish = false;
- autocreate_on_subscribe = false;
+ autocreate_on_publish = true;
+ autocreate_on_subscribe = true;
nodestore = nodestore(room_jid);
itemstore = simple_itemstore(room_jid);
@@ -234,14 +236,17 @@ function get_mep_service(room_jid, room_host)
-- subscriber_filter = get_subscriber_filter(room_jid);
itemcheck = is_item_stanza;
get_affiliation = function (jid)
+ -- module:log("debug", "get_affiliation call for %q", jid);
-- First checking if there is an affiliation on the room for this JID.
local actor_jid = jid_bare(jid);
local room_affiliation = room:get_affiliation(actor_jid);
-- if user is banned, don't go any further
if (room_affiliation == "outcast") then
+ -- module:log("debug", "get_affiliation for %q: outcast (existing room affiliation)", jid);
return "outcast";
end
if (room_affiliation == "owner" or room_affiliation == "admin") then
+ -- 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)
end
@@ -250,11 +255,13 @@ function get_mep_service(room_jid, room_host)
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!
+ -- module:log("debug", "get_affiliation for %q: outcast", jid);
return "outcast";
end;