Commit graph

127 commits

Author SHA1 Message Date
Kim Alvefur
43531740f9 util: Prefix module imports with prosody namespace 2023-03-17 16:23:16 +01:00
Kim Alvefur
8a97d634a4 util.pubsub: Fix item store resize to "max"
Previously this would end up passing the "max" directly to the
underlying storage.
2022-01-06 01:18:35 +01:00
Kim Alvefur
4b05d0f240 mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Default left as 'never' in mod_pubsub to preserve the previous behavior.
Unclear if this is desirable, but can always be changed later.

In mod_pep this allows turning off the automatic resending of most
recent item.
2021-10-19 18:11:50 +02:00
Kim Alvefur
1546e59310 util.pubsub: Add support for limiting number of items to retrieve
Hopefully this will eventually be upgraded to RSM, which is why the
argument is called 'resultspec' and is a table.
2021-09-05 16:21:10 +02:00
Kim Alvefur
dfed446a5a util.pubsub: Signal that 'persistent-items' is unsupported when disabled
XEP-0060 says that this the way to indicate that 'persistent-items' is
unsupported, but doesn't explicitly say if it being disabled in the node
configuration also counts as unsupported.
2021-07-22 19:53:21 +02:00
Kim Alvefur
ffeeffd35c util.pubsub: Fix behavior of persist_items disabled
When set to 'false' there is no need for a persistence interface at all,
since items are not persisted after being broadcast.

Had started wondering if maybe the behavior was wrong, after reading
parts of XEP-0060 that pointed in that direction.

Some discussion of this can be found in logs of
xmpp:xsf@muc.xmpp.org?join from around 2021-07-20

Thanks to Ralph for confirming.
2021-07-22 21:01:11 +02:00
Kim Alvefur
8116134258 mod_pubsub: Explicitly enable persistence by default to preserve behavior
Since nodes were always persistent according to the XEP-0060 definition.
Whether data is stored in memory or on disk was not what this setting
was meant for.
2021-07-21 23:35:08 +02:00
Kim Alvefur
3756e3c835 util.pubsub: Handle absence of node data interface
This is in preparation for fixing the behavior of 'persist_items', which
was misunderstood at some point. In mod_pep it toggles between
persistent storage and in-memory storage, while the correct behavior
would be to toggle whether published items are stored at all or
forgotten after being broadcast.
2021-07-21 21:22:17 +02:00
Kim Alvefur
f650ac5537 Merge 0.11->trunk 2021-05-16 19:05:20 +02:00
Kim Alvefur
0e1bf3c061 util.pubsub: Fix traceback if node data not initialized
This should not be possible, but a traceback indicating node_data being
nil here was reported by Ron in the chat.
2021-05-16 16:02:00 +02:00
Kim Alvefur
0c9d47f6ff util.pubsub: Silence luacheck warnings, leaving notes on future proper fix 2019-12-23 21:16:10 +01:00
Kim Alvefur
7ebf9bf1bf Merge 0.11->trunk 2019-12-23 20:57:10 +01:00
Kim Alvefur
f6592c459e util.pubsub: Pass subscribers trough a filter callback 2019-06-06 18:13:46 +02:00
Kim Alvefur
9be2ed1c4b util.pubsub: Factor out calling of broadcaster
This will simplify doing things along with broadcasting.
2019-06-06 17:37:15 +02:00
Matthew Wild
b5b9b70c88 util.pubsub, pubsub.lib and tests: Add text to precondition-not-met error (fixes #1455) 2019-10-27 14:45:57 +00:00
Kim Alvefur
5d4504e51b util.pubsub: Validate node configuration on node creation (fixes #1328) 2019-03-03 19:31:56 +01:00
Kim Alvefur
da56744645 util.pubsub: Add support for requesting multiple specific items (needed for #1305) 2019-01-28 01:41:01 +01:00
Kim Alvefur
9f19a48ee2 util.pubsub: Restore subscription index from stored data (fixes #1281) 2018-12-29 21:47:51 +01:00
Kim Alvefur
eaac53d041 util.pubsub: Clarify comment about return value 2018-10-21 22:21:18 +02:00
Matthew Wild
44b3954d56 util.pubsub: Allow publishing with a config that should be used as defaults only 2018-10-18 18:00:54 +01:00
Kim Alvefur
fb2fdc660b util.pubsub: Expand comment on return type from get_items 2018-09-01 00:45:51 +02:00
Kim Alvefur
a60bb9bb13 util.pubsub: Explicitly add all capabilities to the 'outcast' affiliation for completeness 2018-08-31 17:49:14 +02:00
Kim Alvefur
df5360e6a3 util.pubsub: Comments describing the return values of methods 2018-08-22 13:27:36 +02:00
Matthew Wild
11c4cee97a util.pubsub: Add 'service' field to all events 2018-08-27 14:07:28 +01:00
Kim Alvefur
dedea4fb31 util.pubsub: Remove unused argument
I think this was probably a copy-paste mistake.
2018-08-21 19:48:08 +02:00
Matthew Wild
99b85eda32 util.pubsub: Fire item-published/<node> to allow for easier handling of per-node items 2018-08-19 23:37:19 +01:00
Matthew Wild
512d844d91 util.pubsub, pubsub.lib: Improve error on attempt to publish invalid item 2018-08-18 15:26:35 +01:00
Matthew Wild
23cfd1b4d0 Pubsub: Add tests for :get_last_item() and fix for non-persistent nodes 2018-08-18 15:10:41 +01:00
Matthew Wild
0a0695d96b util.pubsub: Fix whitespace [luacheck] 2018-08-18 14:33:49 +01:00
Matthew Wild
6e48cd5ece Backed out changeset 27d800ddc3b0 (see below)
It's uncertain whether item not existing should be success and
nil, or fail with an error.

XEP-0060's "fetch most recent item" actually fetches a list of up
to N items. N here is a maximum, not a minimum. The feeling is that
no items is simply an empty list, not a failure of the operation.
2018-08-18 14:30:14 +01:00
Matthew Wild
6ff958994e util.pubsub: get_last_item(): Fail with item-not-found if no item yet published 2018-08-18 14:21:02 +01:00
Matthew Wild
6643aeb7e6 util.pubsub: get_last_item(): Return error if node does not exist 2018-08-18 14:17:43 +01:00
Matthew Wild
716c68f983 pubsub.lib, util.pubsub: Move precondition checks to util.pubsub 2018-08-18 14:06:56 +01:00
Matthew Wild
fe83df56a9 util.pubsub: Add comment to clarify return values 2018-08-18 13:23:52 +01:00
Kim Alvefur
98c9778cc7 util.pubsub: Pass "retract" as the type of such broadcasts
This moves some XEP-0060 awkwardness out of util.pubsub and into mod_pubsub

A retraction is broadcast in an <items> container, whereas most other
kinds of broadcasts are in a container with a name matching the 'kind'
attribute.
2018-08-16 14:32:21 +02:00
Matthew Wild
a86ca3faa1 util.pubsub: Allow outcasts to get their subscription status 2018-08-12 11:33:22 +01:00
Matthew Wild
1a41278b49 util.pubsub: For open nodes, default affiliation is "member"
This allows entities without an explicit affiliation to retrieve items,
which is specified by the XEP. Table 6: "Node Access Models" states that
for 'open' nodes, "any entity may retrieve items from the node".

See also discussion at:
 https://mail.jabber.org/pipermail/standards/2018-August/035320.html
2018-08-09 20:27:04 +01:00
Matthew Wild
7df3613768 mod_pep, util.pubsub: Rename restricted->outcast, none->member and add new 'none' affiliation to better match XEP-0060 2018-08-08 23:20:07 +01:00
Matthew Wild
ff222c379d mod_pubsub, mod_pep, util.pubsub: Move capability definitions into util.pubsub to avoid duplication 2018-08-08 20:48:02 +01:00
Kim Alvefur
5a5354e422 util.pubsub: Include node defaults from current service object 2018-08-07 10:52:10 +02:00
Kim Alvefur
4b848862f5 util.pubsub: Re-check all subscriptions on access_model change, unsubscribing those no longer allowed 2018-08-06 17:04:11 +02:00
Matthew Wild
711d3e4bf3 util.pubsub: Add support for publish_model config option 2018-08-06 11:23:09 +01:00
Kim Alvefur
2b8327099a util.pubsub: Apply defaults metatable before config check (thanks pep.)
Makes it so that the callback sees the default if it’s not in the form,
which makes it easier to validate.
2018-08-05 15:17:00 +02:00
Matthew Wild
43c1195531 util.pubsub: Add method to retrieve node configuration 2018-08-04 21:32:24 +01:00
Matthew Wild
62fd30552e util.pubsub: Use service.node_defaults in case config.node_defaults was not provided (thanks jonasw) 2018-08-04 21:30:10 +01:00
Matthew Wild
31e2ba5f99 util.pubsub: Tweak default affiliation of access models (fixes failing test)
11:56:59 MattJ> Someone who has the ability to subscribe does not have the "subscriber"
affiliation until they actually subscribe, they just have the normal "none" affiliation
(which has permission to subscribe)

11:58:05 MattJ> However if the access model is whitelist, then anyone not on the whitelist
has an implicit negative affiliation, which we don't currently have, so I just named "restricted"

11:58:16 MattJ> Since it doesn't exist in any code yet, it has no permissions
2018-08-04 12:00:46 +01:00
Kim Alvefur
d9abcdd048 util.pubsub: Look for a configured callback for more complicated access models 2018-08-04 03:04:00 +02:00
Kim Alvefur
afd936d00c util.pubsub: Add initial support for configurable access models 2018-08-04 03:38:20 +02:00
Matthew Wild
82655ffa2b util.pubsub: Add support for a config validation function 2018-08-01 19:18:07 +01:00
Kim Alvefur
fc5c354891 util.pubsub: Support for returning *all* subscriptions 2018-07-13 04:41:59 +02:00