Mercurial > prosody-hg
comparison plugins/mod_blocklist.lua @ 6972:9e926e48cbf9
mod_blocklist: session[username] can't possibly be unset if that user is sending queries
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 06 Dec 2015 02:19:04 +0100 |
| parents | 96080d86bab8 |
| children | f350f840a6f7 |
comparison
equal
deleted
inserted
replaced
| 6971:96080d86bab8 | 6972:9e926e48cbf9 |
|---|---|
| 160 return true; | 160 return true; |
| 161 end | 161 end |
| 162 | 162 |
| 163 if is_blocking then | 163 if is_blocking then |
| 164 for jid, in_roster in pairs(new) do | 164 for jid, in_roster in pairs(new) do |
| 165 if not blocklist[jid] and in_roster and sessions[username] then | 165 if not blocklist[jid] and in_roster then |
| 166 for _, session in pairs(sessions[username].sessions) do | 166 for _, session in pairs(sessions[username].sessions) do |
| 167 if session.presence then | 167 if session.presence then |
| 168 module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid })); | 168 module:send(st.presence({ type = "unavailable", to = jid, from = session.full_jid })); |
| 169 end | 169 end |
| 170 end | 170 end |
| 171 end | 171 end |
| 172 end | 172 end |
| 173 end | 173 end |
| 174 if sessions[username] then | 174 |
| 175 local blocklist_push = st.iq({ type = "set", id = "blocklist-push" }) | 175 local blocklist_push = st.iq({ type = "set", id = "blocklist-push" }) |
| 176 :add_child(action); -- I am lazy | 176 :add_child(action); -- I am lazy |
| 177 | 177 |
| 178 for _, session in pairs(sessions[username].sessions) do | 178 for _, session in pairs(sessions[username].sessions) do |
| 179 if session.interested_blocklist then | 179 if session.interested_blocklist then |
| 180 blocklist_push.attr.to = session.full_jid; | 180 blocklist_push.attr.to = session.full_jid; |
| 181 session.send(blocklist_push); | 181 session.send(blocklist_push); |
| 182 end | |
| 183 end | 182 end |
| 184 end | 183 end |
| 185 | 184 |
| 186 return true; | 185 return true; |
| 187 end | 186 end |
