Software /
code /
prosody
Comparison
plugins/mod_blocklist.lua @ 10053:4b2cc8a60449
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 20 Jun 2019 21:40:27 +0200 |
parent | 9993:02a41315d275 |
parent | 10052:0c35f353db68 |
child | 10054:0656bd283fa2 |
comparison
equal
deleted
inserted
replaced
10049:c523642ea293 | 10053:4b2cc8a60449 |
---|---|
126 -- > When the user blocks communications with the contact, the user's | 126 -- > When the user blocks communications with the contact, the user's |
127 -- > server MUST send unavailable presence information to the contact (but | 127 -- > server MUST send unavailable presence information to the contact (but |
128 -- > only if the contact is allowed to receive presence notifications [...] | 128 -- > only if the contact is allowed to receive presence notifications [...] |
129 -- So contacts we need to do that for are added to the set below. | 129 -- So contacts we need to do that for are added to the set below. |
130 local send_unavailable = is_blocking and {}; | 130 local send_unavailable = is_blocking and {}; |
131 local send_available = not is_blocking and {}; | |
131 | 132 |
132 -- Because blocking someone currently also blocks the ability to reject | 133 -- Because blocking someone currently also blocks the ability to reject |
133 -- subscription requests, we'll preemptively reject such | 134 -- subscription requests, we'll preemptively reject such |
134 local remove_pending = is_blocking and {}; | 135 local remove_pending = is_blocking and {}; |
135 | 136 |
145 if is_contact_subscribed(username, module.host, jid) then | 146 if is_contact_subscribed(username, module.host, jid) then |
146 send_unavailable[jid] = true; | 147 send_unavailable[jid] = true; |
147 elseif is_contact_pending_in(username, module.host, jid) then | 148 elseif is_contact_pending_in(username, module.host, jid) then |
148 remove_pending[jid] = true; | 149 remove_pending[jid] = true; |
149 end | 150 end |
151 elseif is_contact_subscribed(username, module.host, jid) then | |
152 send_available[jid] = true; | |
150 end | 153 end |
151 end | 154 end |
152 | 155 |
153 if is_blocking and not next(new) then | 156 if is_blocking and not next(new) then |
154 -- <block/> element does not contain at least one <item/> child element | 157 -- <block/> element does not contain at least one <item/> child element |
201 roster[false].pending[jid] = nil; | 204 roster[false].pending[jid] = nil; |
202 end | 205 end |
203 save_roster(username, module.host, roster); | 206 save_roster(username, module.host, roster); |
204 -- Not much we can do about save failing here | 207 -- Not much we can do about save failing here |
205 end | 208 end |
209 else | |
210 local user_bare = username .. "@" .. module.host; | |
211 for jid in pairs(send_available) do | |
212 module:send(st.presence({ type = "probe", to = user_bare, from = jid })); | |
213 end | |
206 end | 214 end |
207 | 215 |
208 local blocklist_push = st.iq({ type = "set", id = "blocklist-push" }) | 216 local blocklist_push = st.iq({ type = "set", id = "blocklist-push" }) |
209 :add_child(action); -- I am lazy | 217 :add_child(action); -- I am lazy |
210 | 218 |