Annotate

plugins/mod_pep_plus.lua @ 6444:aab509a9d0ba

mod_pep_plus: Default to max one item per node (Recomended for PEP)
author Kim Alvefur <zash@zash.se>
date Sun, 28 Sep 2014 02:00:44 +0200
parent 6443:f4403c270ea2
child 6449:24cd03cd1847
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
1 local pubsub = require "util.pubsub";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
2 local jid_bare = require "util.jid".bare;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
3 local jid_split = require "util.jid".split;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
4 local set_new = require "util.set".new;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
5 local st = require "util.stanza";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
6 local calculate_hash = require "util.caps".calculate_hash;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
7 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
8
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
9 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
10 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
11 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
12
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
13 local lib_pubsub = module:require "pubsub";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
14 local handlers = lib_pubsub.handlers;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
15 local pubsub_error_reply = lib_pubsub.pubsub_error_reply;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
16
6305
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
17 local empty_set = set_new();
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
18
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
19 local services = {};
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
20 local recipients = {};
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
21 local hash_map = {};
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
22
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
23 function module.save()
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
24 return { services = services };
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
25 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
26
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
27 function module.restore(data)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
28 services = data.services;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
29 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
30
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
31 local function subscription_presence(user_bare, recipient)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
32 local recipient_bare = jid_bare(recipient);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
33 if (recipient_bare == user_bare) then return true; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
34 local username, host = jid_split(user_bare);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
35 return is_contact_subscribed(username, host, recipient_bare);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
36 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
37
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
38 local function get_broadcaster(name)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
39 local function simple_broadcast(kind, node, jids, item)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
40 if item then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
41 item = st.clone(item);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
42 item.attr.xmlns = nil; -- Clear the pubsub namespace
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
43 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
44 local message = st.message({ from = name, type = "headline" })
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
45 :tag("event", { xmlns = xmlns_pubsub_event })
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
46 :tag(kind, { node = node })
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
47 :add_child(item);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
48 for jid in pairs(jids) do
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
49 module:log("debug", "Sending notification to %s from %s: %s", jid, name, tostring(item));
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
50 message.attr.to = jid;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
51 module:send(message);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
52 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
53 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
54 return simple_broadcast;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
55 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
56
6264
12a083299bb7 mod_pep_plus: Expose get_pep_service()
Kim Alvefur <zash@zash.se>
parents: 5852
diff changeset
57 function get_pep_service(name)
6432
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
58 local service = services[name];
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
59 if service then
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
60 return service;
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
61 end
6432
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
62 service = pubsub.new({
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
63 capabilities = {
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
64 none = {
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
65 create = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
66 publish = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
67 retract = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
68 get_nodes = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
69
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
70 subscribe = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
71 unsubscribe = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
72 get_subscription = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
73 get_subscriptions = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
74 get_items = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
75
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
76 subscribe_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
77 unsubscribe_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
78 get_subscription_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
79 get_subscriptions_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
80
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
81 be_subscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
82 be_unsubscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
83
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
84 set_affiliation = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
85 };
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
86 subscriber = {
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
87 create = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
88 publish = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
89 retract = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
90 get_nodes = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
91
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
92 subscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
93 unsubscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
94 get_subscription = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
95 get_subscriptions = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
96 get_items = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
97
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
98 subscribe_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
99 unsubscribe_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
100 get_subscription_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
101 get_subscriptions_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
102
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
103 be_subscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
104 be_unsubscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
105
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
106 set_affiliation = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
107 };
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
108 publisher = {
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
109 create = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
110 publish = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
111 retract = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
112 get_nodes = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
113
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
114 subscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
115 unsubscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
116 get_subscription = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
117 get_subscriptions = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
118 get_items = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
119
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
120 subscribe_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
121 unsubscribe_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
122 get_subscription_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
123 get_subscriptions_other = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
124
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
125 be_subscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
126 be_unsubscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
127
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
128 set_affiliation = false;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
129 };
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
130 owner = {
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
131 create = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
132 publish = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
133 retract = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
134 delete = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
135 get_nodes = true;
6443
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
136 configure = true;
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
137
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
138 subscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
139 unsubscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
140 get_subscription = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
141 get_subscriptions = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
142 get_items = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
143
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
144
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
145 subscribe_other = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
146 unsubscribe_other = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
147 get_subscription_other = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
148 get_subscriptions_other = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
149
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
150 be_subscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
151 be_unsubscribed = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
152
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
153 set_affiliation = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
154 };
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
155 };
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
156
6444
aab509a9d0ba mod_pep_plus: Default to max one item per node (Recomended for PEP)
Kim Alvefur <zash@zash.se>
parents: 6443
diff changeset
157 node_defaults = {
aab509a9d0ba mod_pep_plus: Default to max one item per node (Recomended for PEP)
Kim Alvefur <zash@zash.se>
parents: 6443
diff changeset
158 ["pubsub#max_items"] = "1";
aab509a9d0ba mod_pep_plus: Default to max one item per node (Recomended for PEP)
Kim Alvefur <zash@zash.se>
parents: 6443
diff changeset
159 };
aab509a9d0ba mod_pep_plus: Default to max one item per node (Recomended for PEP)
Kim Alvefur <zash@zash.se>
parents: 6443
diff changeset
160
6443
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
161 node_config_form = require"util.dataforms".new {
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
162 {
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
163 type = "hidden";
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
164 name = "FORM_TYPE";
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
165 value = "http://jabber.org/protocol/pubsub#node_config";
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
166 };
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
167 {
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
168 type = "text-single";
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
169 name = "pubsub#max_items";
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
170 label = "Max # of items to persist";
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
171 };
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
172 };
f4403c270ea2 mod_pep_plus: Add node config form
Kim Alvefur <zash@zash.se>
parents: 6432
diff changeset
173
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
174 autocreate_on_publish = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
175 autocreate_on_subscribe = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
176
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
177 broadcaster = get_broadcaster(name);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
178 get_affiliation = function (jid)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
179 if jid_bare(jid) == name then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
180 return "owner";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
181 elseif subscription_presence(name, jid) then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
182 return "subscriber";
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
183 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
184 end;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
185
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
186 normalize_jid = jid_bare;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
187 });
6432
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
188 services[name] = service;
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
189 module:add_item("pep-service", { service = service, jid = name });
388786af0dd2 mod_pep_plus: Add pubsub service objects to an item list
Kim Alvefur <zash@zash.se>
parents: 6305
diff changeset
190 return service;
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
191 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
192
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
193 function handle_pubsub_iq(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
194 local origin, stanza = event.origin, event.stanza;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
195 local pubsub = stanza.tags[1];
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
196 local action = pubsub.tags[1];
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
197 if not action then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
198 return origin.send(st.error_reply(stanza, "cancel", "bad-request"));
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
199 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
200 local service_name = stanza.attr.to or origin.username.."@"..origin.host
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
201 local service = get_pep_service(service_name);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
202 local handler = handlers[stanza.attr.type.."_"..action.name];
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
203 if handler then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
204 handler(origin, stanza, action, service);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
205 return true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
206 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
207 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
208
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
209 module:hook("iq/bare/"..xmlns_pubsub..":pubsub", handle_pubsub_iq);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
210 module:hook("iq/bare/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
211
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
212 module:add_identity("pubsub", "pep", module:get_option_string("name", "Prosody"));
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
213 module:add_feature("http://jabber.org/protocol/pubsub#publish");
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
214
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
215 local function get_caps_hash_from_presence(stanza, current)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
216 local t = stanza.attr.type;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
217 if not t then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
218 local child = stanza:get_child("c", "http://jabber.org/protocol/caps");
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
219 if child then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
220 local attr = child.attr;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
221 if attr.hash then -- new caps
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
222 if attr.hash == 'sha-1' and attr.node and attr.ver then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
223 return attr.ver, attr.node.."#"..attr.ver;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
224 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
225 else -- legacy caps
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
226 if attr.node and attr.ver then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
227 return attr.node.."#"..attr.ver.."#"..(attr.ext or ""), attr.node.."#"..attr.ver;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
228 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
229 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
230 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
231 return; -- no or bad caps
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
232 elseif t == "unavailable" or t == "error" then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
233 return;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
234 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
235 return current; -- no caps, could mean caps optimization, so return current
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
236 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
237
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
238 local function resend_last_item(jid, node, service)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
239 local ok, items = service:get_items(node, jid);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
240 if not ok then return; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
241 for i, id in ipairs(items) do
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
242 service.config.broadcaster("items", node, { [jid] = true }, items[id]);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
243 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
244 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
245
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
246 local function update_subscriptions(recipient, service_name, nodes)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
247 local service = get_pep_service(service_name);
6305
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
248 nodes = nodes or empty_set;
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
249
6305
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
250 local service_recipients = recipients[service_name];
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
251 if not service_recipients then
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
252 service_recipients = {};
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
253 recipients[service_name] = service_recipients;
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
254 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
255
6305
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
256 local current = service_recipients[recipient];
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
257 if not current or type(current) ~= "table" then
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
258 current = empty_set;
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
259 end
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
260
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
261 if (current == empty_set or current:empty()) and (nodes == empty_set or nodes:empty()) then
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
262 return;
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
263 end
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
264
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
265 for node in current - nodes do
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
266 service:remove_subscription(node, recipient, recipient);
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
267 end
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
268
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
269 for node in nodes - current do
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
270 service:add_subscription(node, recipient, recipient);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
271 resend_last_item(recipient, node, service);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
272 end
6305
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
273
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
274 if nodes == empty_set or nodes:empty() then
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
275 nodes = nil;
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
276 end
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
277
38d82f8ead25 mod_pep_plus: Only broadcast newly added subscriptions
Kim Alvefur <zash@zash.se>
parents: 6264
diff changeset
278 service_recipients[recipient] = nodes;
5852
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
279 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
280
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
281 module:hook("presence/bare", function(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
282 -- inbound presence to bare JID recieved
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
283 local origin, stanza = event.origin, event.stanza;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
284 local user = stanza.attr.to or (origin.username..'@'..origin.host);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
285 local t = stanza.attr.type;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
286 local self = not stanza.attr.to;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
287 local service = get_pep_service(user);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
288
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
289 if not t then -- available presence
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
290 if self or subscription_presence(user, stanza.attr.from) then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
291 local recipient = stanza.attr.from;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
292 local current = recipients[user] and recipients[user][recipient];
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
293 local hash, query_node = get_caps_hash_from_presence(stanza, current);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
294 if current == hash or (current and current == hash_map[hash]) then return; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
295 if not hash then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
296 update_subscriptions(recipient, user);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
297 else
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
298 recipients[user] = recipients[user] or {};
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
299 if hash_map[hash] then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
300 update_subscriptions(recipient, user, hash_map[hash]);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
301 else
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
302 recipients[user][recipient] = hash;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
303 local from_bare = origin.type == "c2s" and origin.username.."@"..origin.host;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
304 if self or origin.type ~= "c2s" or (recipients[from_bare] and recipients[from_bare][origin.full_jid]) ~= hash then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
305 -- COMPAT from ~= stanza.attr.to because OneTeam can't deal with missing from attribute
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
306 origin.send(
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
307 st.stanza("iq", {from=user, to=stanza.attr.from, id="disco", type="get"})
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
308 :tag("query", {xmlns = "http://jabber.org/protocol/disco#info", node = query_node})
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
309 );
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
310 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
311 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
312 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
313 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
314 elseif t == "unavailable" then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
315 update_subscriptions(stanza.attr.from, user);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
316 elseif not self and t == "unsubscribe" then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
317 local from = jid_bare(stanza.attr.from);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
318 local subscriptions = recipients[user];
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
319 if subscriptions then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
320 for subscriber in pairs(subscriptions) do
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
321 if jid_bare(subscriber) == from then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
322 update_subscriptions(subscriber, user);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
323 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
324 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
325 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
326 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
327 end, 10);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
328
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
329 module:hook("iq-result/bare/disco", function(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
330 local origin, stanza = event.origin, event.stanza;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
331 local disco = stanza:get_child("query", "http://jabber.org/protocol/disco#info");
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
332 if not disco then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
333 return;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
334 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
335
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
336 -- Process disco response
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
337 local self = not stanza.attr.to;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
338 local user = stanza.attr.to or (origin.username..'@'..origin.host);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
339 local contact = stanza.attr.from;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
340 local current = recipients[user] and recipients[user][contact];
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
341 if type(current) ~= "string" then return; end -- check if waiting for recipient's response
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
342 local ver = current;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
343 if not string.find(current, "#") then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
344 ver = calculate_hash(disco.tags); -- calculate hash
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
345 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
346 local notify = set_new();
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
347 for _, feature in pairs(disco.tags) do
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
348 if feature.name == "feature" and feature.attr.var then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
349 local nfeature = feature.attr.var:match("^(.*)%+notify$");
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
350 if nfeature then notify:add(nfeature); end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
351 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
352 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
353 hash_map[ver] = notify; -- update hash map
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
354 if self then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
355 for jid, item in pairs(origin.roster) do -- for all interested contacts
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
356 if item.subscription == "both" or item.subscription == "from" then
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
357 if not recipients[jid] then recipients[jid] = {}; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
358 update_subscriptions(contact, jid, notify);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
359 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
360 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
361 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
362 update_subscriptions(contact, user, notify);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
363 end);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
364
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
365 module:hook("account-disco-info-node", function(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
366 local reply, stanza, origin = event.reply, event.stanza, event.origin;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
367 local service_name = stanza.attr.to or origin.username.."@"..origin.host
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
368 local service = get_pep_service(service_name);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
369 local node = event.node;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
370 local ok = service:get_items(node, jid_bare(stanza.attr.from) or true);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
371 if not ok then return; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
372 event.exists = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
373 reply:tag('identity', {category='pubsub', type='leaf'}):up();
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
374 end);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
375
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
376 module:hook("account-disco-info", function(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
377 local reply = event.reply;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
378 reply:tag('identity', {category='pubsub', type='pep'}):up();
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
379 reply:tag('feature', {var='http://jabber.org/protocol/pubsub#publish'}):up();
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
380 end);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
381
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
382 module:hook("account-disco-items-node", function(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
383 local reply, stanza, origin = event.reply, event.stanza, event.origin;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
384 local node = event.node;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
385 local service_name = stanza.attr.to or origin.username.."@"..origin.host
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
386 local service = get_pep_service(service_name);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
387 local ok, ret = service:get_items(node, jid_bare(stanza.attr.from) or true);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
388 if not ok then return; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
389 event.exists = true;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
390 for _, id in ipairs(ret) do
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
391 reply:tag("item", { jid = service_name, name = id }):up();
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
392 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
393 end);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
394
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
395 module:hook("account-disco-items", function(event)
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
396 local reply, stanza, origin = event.reply, event.stanza, event.origin;
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
397
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
398 local service_name = reply.attr.from or origin.username.."@"..origin.host
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
399 local service = get_pep_service(service_name);
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
400 local ok, ret = service:get_nodes(jid_bare(stanza.attr.from));
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
401 if not ok then return; end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
402
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
403 for node, node_obj in pairs(ret) do
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
404 reply:tag("item", { jid = service_name, node = node, name = node_obj.config.name }):up();
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
405 end
84bdac93910f mod_pep_plus: An util.pubsub based PEP module
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
406 end);