Mercurial > prosody-modules
comparison mod_privacy/mod_privacy.lua @ 46:ea756d96584f
mod_privacy: nicer debug logging ...
| author | Thilo Cestonaro <thilo@cestona.ro> |
|---|---|
| date | Fri, 16 Oct 2009 21:30:59 +0200 |
| parents | 3f5bbd7c90d4 |
| children | b07193056935 |
comparison
equal
deleted
inserted
replaced
| 45:3f5bbd7c90d4 | 46:ea756d96584f |
|---|---|
| 321 function checkIfNeedToBeBlocked(e, session) | 321 function checkIfNeedToBeBlocked(e, session) |
| 322 local origin, stanza = e.origin, e.stanza; | 322 local origin, stanza = e.origin, e.stanza; |
| 323 local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {}; | 323 local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {}; |
| 324 local bare_jid = session.username.."@"..session.host; | 324 local bare_jid = session.username.."@"..session.host; |
| 325 | 325 |
| 326 module:log("debug", "stanza: %s, to: %s, from: %s", stanza.name, stanza.attr.to or "nil", stanza.attr.from or "nil"); | 326 module:log("debug", "stanza: %s, to: %s, from: %s", tostring(stanza.name), tostring(stanza.attr.to), tostring(stanza.attr.from)); |
| 327 | 327 |
| 328 if stanza.attr.to ~= nil and stanza.attr.from ~= nil then | 328 if stanza.attr.to ~= nil and stanza.attr.from ~= nil then |
| 329 if privacy_lists.lists == nil or | 329 if privacy_lists.lists == nil or |
| 330 (session.activePrivacyList == nil or session.activePrivacyList == "") and | 330 (session.activePrivacyList == nil or session.activePrivacyList == "") and |
| 331 (privacy_lists.default == nil or privacy_lists.default == "") | 331 (privacy_lists.default == nil or privacy_lists.default == "") |
| 404 block = (item.action == "deny"); | 404 block = (item.action == "deny"); |
| 405 end | 405 end |
| 406 end | 406 end |
| 407 if apply then | 407 if apply then |
| 408 if block then | 408 if block then |
| 409 module:log("info", "stanza blocked: %s, to: %s, from: %s", stanza.name, stanza.attr.to or "nil", stanza.attr.from or "nil"); | 409 module:log("info", "stanza blocked: %s, to: %s, from: %s", tostring(stanza.name), tostring(stanza.attr.to), tostring(stanza.attr.from)); |
| 410 if stanza.name == "message" then | 410 if stanza.name == "message" then |
| 411 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | 411 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); |
| 412 elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then | 412 elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then |
| 413 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | 413 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); |
| 414 end | 414 end |
| 445 session = full_sessions[node.."@"..host.."/"..resource]; | 445 session = full_sessions[node.."@"..host.."/"..resource]; |
| 446 end | 446 end |
| 447 if session ~= nil then | 447 if session ~= nil then |
| 448 return checkIfNeedToBeBlocked(e, session); | 448 return checkIfNeedToBeBlocked(e, session); |
| 449 else | 449 else |
| 450 module:log("debug", "preCheckIncoming: Couldn't get session for jid: %s@%s/%s", node or "nil", host or "nil", resource or "nil") | 450 module:log("debug", "preCheckIncoming: Couldn't get session for jid: %s@%s/%s", tostring(node), tostring(host), tostring(resource)) |
| 451 end | 451 end |
| 452 end | 452 end |
| 453 return; | 453 return; |
| 454 end | 454 end |
| 455 | 455 |
