diff --git a/CHANGELOG.md b/CHANGELOG.md index cdbfcf5b6d..10407d9395 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 10.3.2 + +### Minor changes and fixes + +* Fix #477: ended polls never disappear when archiving is disabled (and no more than 20 new messages). + ## 10.3.1 ### Minor changes and fixes diff --git a/conversejs/custom/plugins/poll/index.js b/conversejs/custom/plugins/poll/index.js index d7e94b0cb6..6e08b5c887 100644 --- a/conversejs/custom/plugins/poll/index.js +++ b/conversejs/custom/plugins/poll/index.js @@ -12,6 +12,8 @@ import './components/poll-form-view.js' const { sizzle } = converse.env +const delayedTimeout = 2 // for delayed poll message, how long must the be considered as valid. + converse.plugins.add('livechat-converse-poll', { dependencies: ['converse-muc', 'converse-disco'], @@ -97,6 +99,23 @@ converse.plugins.add('livechat-converse-poll', { if (attrs.is_archived) { return this.__super__.onMessage(attrs) } + if (attrs.is_delayed) { + // When archiving is disabled, the "history" mechanism is still available: + // Last X (20 by default) messages will be kept, and sent to users. + // The only thing that differentiates such messages is that they are delayed. + // We can't just ignore all delayed messages, because if one day we enable SMACKS + // (to handle deconnections on poor network), there could be some legitimate delayed messages. + // So we will only ignore the poll if it was sent more than X minutes ago. + console.debug('Got a delayed poll message, checking if old or not') + const d = new Date() + d.setMinutes(d.getMinutes() - delayedTimeout) + if (attrs.time < d.toISOString()) { + console.debug( + `Poll message was delayed fore more than ${delayedTimeout} minutes (${attrs.time} < ${d.toISOString()}).` + ) + return this.__super__.onMessage(attrs) + } + } console.info('Got a poll message, setting it as the current_poll') // this will be displayed by the livechat-converse-muc-poll custom element, diff --git a/package-lock.json b/package-lock.json index 0788ce8051..501b92e880 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "peertube-plugin-livechat", - "version": "10.3.1", + "version": "10.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "peertube-plugin-livechat", - "version": "10.3.1", + "version": "10.3.2", "license": "AGPL-3.0", "dependencies": { "@xmpp/jid": "^0.13.1", diff --git a/package.json b/package.json index c6827b76e7..419b0db086 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "peertube-plugin-livechat", "description": "PeerTube plugin livechat: create chat rooms for your Peertube lives! Comes with many features: federation, moderation tools, chat bot, chat persistence, OBS integration, ...", - "version": "10.3.1", + "version": "10.3.2", "license": "AGPL-3.0", "author": { "name": "John Livingston",