Software /
code /
prosody
Comparison
plugins/mod_privacy.lua @ 2516:68a889016a46
mod_privacy: Trailing whitespace (I can't sleep)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 29 Jan 2010 02:16:43 +0000 |
parent | 2502:ec3eaf54bbd4 |
child | 2517:d0c43c4dcb3f |
comparison
equal
deleted
inserted
replaced
2515:50517948705c | 2516:68a889016a46 |
---|---|
100 if item.type == "jid" then | 100 if item.type == "jid" then |
101 sendUnavailable(origin, origin.full_jid, item.value); | 101 sendUnavailable(origin, origin.full_jid, item.value); |
102 elseif item.type == "group" then | 102 elseif item.type == "group" then |
103 elseif item.type == "subscription" then | 103 elseif item.type == "subscription" then |
104 elseif item.type == nil then | 104 elseif item.type == nil then |
105 end | 105 end |
106 end | 106 end |
107 else | 107 else |
108 module:log("debug", "got unknown type: %s", type(listnameOrItem)); | 108 module:log("debug", "got unknown type: %s", type(listnameOrItem)); |
109 end | 109 end |
110 end | 110 end |
198 return {"modify", "bad-request", "Order attribute not valid."}; | 198 return {"modify", "bad-request", "Order attribute not valid."}; |
199 end | 199 end |
200 | 200 |
201 if item.attr.type ~= nil and item.attr.type ~= "jid" and item.attr.type ~= "subscription" and item.attr.type ~= "group" then | 201 if item.attr.type ~= nil and item.attr.type ~= "jid" and item.attr.type ~= "subscription" and item.attr.type ~= "group" then |
202 return {"modify", "bad-request", "Type attribute not valid."}; | 202 return {"modify", "bad-request", "Type attribute not valid."}; |
203 end | 203 end |
204 | 204 |
205 local tmp = {}; | 205 local tmp = {}; |
206 orderCheck[item.attr.order] = true; | 206 orderCheck[item.attr.order] = true; |
207 | 207 |
208 tmp["type"] = item.attr.type; | 208 tmp["type"] = item.attr.type; |
250 | 250 |
251 if tmp.action ~= "deny" and tmp.action ~= "allow" then | 251 if tmp.action ~= "deny" and tmp.action ~= "allow" then |
252 return {"cancel", "bad-request", "Action must be either deny or allow."}; | 252 return {"cancel", "bad-request", "Action must be either deny or allow."}; |
253 end | 253 end |
254 | 254 |
255 --[[ | 255 --[[ |
256 if (privacy_lists.default == name and origin.activePrivacyList == nil) or origin.activePrivacyList == name then | 256 if (privacy_lists.default == name and origin.activePrivacyList == nil) or origin.activePrivacyList == name then |
257 module:log("debug", "calling sendNeededUnavailablePresences!"); | 257 module:log("debug", "calling sendNeededUnavailablePresences!"); |
258 -- item is valid and list is active, so send needed unavailable stanzas | 258 -- item is valid and list is active, so send needed unavailable stanzas |
259 sendNeededUnavailablePersences(origin, tmp); | 259 sendNeededUnavailablePersences(origin, tmp); |
260 end | 260 end |
322 local query = stanza.tags[1]; -- the query element | 322 local query = stanza.tags[1]; -- the query element |
323 local valid = false; | 323 local valid = false; |
324 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {}; | 324 local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or {}; |
325 | 325 |
326 if stanza.attr.type == "set" then | 326 if stanza.attr.type == "set" then |
327 if #query.tags == 1 then -- the <query/> element MUST NOT include more than one child element | 327 if #query.tags == 1 then -- the <query/> element MUST NOT include more than one child element |
328 for _,tag in ipairs(query.tags) do | 328 for _,tag in ipairs(query.tags) do |
329 if tag.name == "active" or tag.name == "default" then | 329 if tag.name == "active" or tag.name == "default" then |
330 if tag.attr.name == nil then -- Client declines the use of active / default list | 330 if tag.attr.name == nil then -- Client declines the use of active / default list |
331 valid = declineList(privacy_lists, origin, stanza, tag.name); | 331 valid = declineList(privacy_lists, origin, stanza, tag.name); |
332 else -- Client requests change of active / default list | 332 else -- Client requests change of active / default list |
381 | 381 |
382 if stanza.attr.to ~= nil and stanza.attr.from ~= nil then | 382 if stanza.attr.to ~= nil and stanza.attr.from ~= nil then |
383 if privacy_lists.lists == nil or | 383 if privacy_lists.lists == nil or |
384 (session.activePrivacyList == nil or session.activePrivacyList == "") and | 384 (session.activePrivacyList == nil or session.activePrivacyList == "") and |
385 (privacy_lists.default == nil or privacy_lists.default == "") | 385 (privacy_lists.default == nil or privacy_lists.default == "") |
386 then | 386 then |
387 return; -- Nothing to block, default is Allow all | 387 return; -- Nothing to block, default is Allow all |
388 end | 388 end |
389 if jid_bare(stanza.attr.from) == bare_jid and jid_bare(stanza.attr.to) == bare_jid then | 389 if jid_bare(stanza.attr.from) == bare_jid and jid_bare(stanza.attr.to) == bare_jid then |
390 module:log("debug", "Never block communications from one of a user's resources to another."); | 390 module:log("debug", "Never block communications from one of a user's resources to another."); |
391 return; -- from one of a user's resource to another => HANDS OFF! | 391 return; -- from one of a user's resource to another => HANDS OFF! |
392 end | 392 end |
393 | 393 |
394 local idx; | 394 local idx; |
395 local list; | 395 local list; |
396 local item; | 396 local item; |
397 local listname = session.activePrivacyList; | 397 local listname = session.activePrivacyList; |
428 evilJid.node, evilJid.host, evilJid.resource = jid_split(stanza.attr.from); | 428 evilJid.node, evilJid.host, evilJid.resource = jid_split(stanza.attr.from); |
429 else | 429 else |
430 module:log("debug", "evil jid is (to): %s", stanza.attr.to); | 430 module:log("debug", "evil jid is (to): %s", stanza.attr.to); |
431 evilJid.node, evilJid.host, evilJid.resource = jid_split(stanza.attr.to); | 431 evilJid.node, evilJid.host, evilJid.resource = jid_split(stanza.attr.to); |
432 end | 432 end |
433 if item.type == "jid" and | 433 if item.type == "jid" and |
434 (evilJid.node and evilJid.host and evilJid.resource and item.value == evilJid.node.."@"..evilJid.host.."/"..evilJid.resource) or | 434 (evilJid.node and evilJid.host and evilJid.resource and item.value == evilJid.node.."@"..evilJid.host.."/"..evilJid.resource) or |
435 (evilJid.node and evilJid.host and item.value == evilJid.node.."@"..evilJid.host) or | 435 (evilJid.node and evilJid.host and item.value == evilJid.node.."@"..evilJid.host) or |
436 (evilJid.host and evilJid.resource and item.value == evilJid.host.."/"..evilJid.resource) or | 436 (evilJid.host and evilJid.resource and item.value == evilJid.host.."/"..evilJid.resource) or |
437 (evilJid.host and item.value == evilJid.host) then | 437 (evilJid.host and item.value == evilJid.host) then |
438 apply = true; | 438 apply = true; |