Mercurial > prosody-hg
comparison plugins/mod_pubsub/pubsub.lib.lua @ 13951:eea166afad9b
mod_pubsub: Implement retrieval of own affiliation(s) #1966
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 16 Sep 2025 20:35:52 +0200 |
| parents | e17ff906d71b |
| children | 3eb39ff813ac |
comparison
equal
deleted
inserted
replaced
| 13948:fc489086e09a | 13951:eea166afad9b |
|---|---|
| 230 | 230 |
| 231 local service_method_feature_map = { | 231 local service_method_feature_map = { |
| 232 add_subscription = { "subscribe", "subscription-options" }; | 232 add_subscription = { "subscribe", "subscription-options" }; |
| 233 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; | 233 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; |
| 234 delete = { "delete-nodes" }; | 234 delete = { "delete-nodes" }; |
| 235 get_items = { "retrieve-items" }; | 235 get_items = { "retrieve-items", "retrieve-affiliations" }; |
| 236 get_subscriptions = { "retrieve-subscriptions" }; | 236 get_subscriptions = { "retrieve-subscriptions" }; |
| 237 node_defaults = { "retrieve-default" }; | 237 node_defaults = { "retrieve-default" }; |
| 238 publish = { "publish", "multi-items", "publish-options" }; | 238 publish = { "publish", "multi-items", "publish-options" }; |
| 239 purge = { "purge-nodes" }; | 239 purge = { "purge-nodes" }; |
| 240 retract = { "delete-items", "retract-items" }; | 240 retract = { "delete-items", "retract-items" }; |
| 791 :add_child(node_config_form:form(service.node_defaults)); | 791 :add_child(node_config_form:form(service.node_defaults)); |
| 792 origin.send(reply); | 792 origin.send(reply); |
| 793 return true; | 793 return true; |
| 794 end | 794 end |
| 795 | 795 |
| 796 function handlers.get_affiliations(origin, stanza, affiliations, service) | |
| 797 local ok, nodes = service:get_nodes(stanza.attr.from); | |
| 798 if not ok then | |
| 799 origin.send(pubsub_error_reply(stanza, err)); | |
| 800 return true; | |
| 801 end | |
| 802 local node = affiliations.attr.node; | |
| 803 if node then | |
| 804 nodes = { [node] = nodes[node] }; | |
| 805 end | |
| 806 | |
| 807 local reply = st.reply(stanza) | |
| 808 :tag("pubsub", { xmlns = xmlns_pubsub }) | |
| 809 :tag("affiliations"); | |
| 810 | |
| 811 local jid = service.config.normalize_jid(stanza.attr.from); | |
| 812 for node, node_obj in pairs(nodes) do | |
| 813 local affiliation = node_obj.affiliations[jid]; | |
| 814 if affiliation then | |
| 815 reply:tag("affiliation", { node = node; affiliation = affiliation }):up(); | |
| 816 end | |
| 817 end | |
| 818 | |
| 819 origin.send(reply); | |
| 820 return true; | |
| 821 end | |
| 822 | |
| 796 function handlers.owner_get_affiliations(origin, stanza, affiliations, service) | 823 function handlers.owner_get_affiliations(origin, stanza, affiliations, service) |
| 797 local node = affiliations.attr.node; | 824 local node = affiliations.attr.node; |
| 798 if not node then | 825 if not node then |
| 799 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 826 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
| 800 return true; | 827 return true; |
