Software / code / prosody
Comparison
plugins/mod_privacy.lua @ 2579:4e0caff152d6
mod_privacy: Rename from_user/to_user flags to is_from_user/is_to_user for clarity
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 09 Feb 2010 06:49:03 +0000 |
| parent | 2524:b427f5401ce7 |
| child | 2588:741302471a23 |
comparison
equal
deleted
inserted
replaced
| 2578:61e5eff54415 | 2579:4e0caff152d6 |
|---|---|
| 377 local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {}; | 377 local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {}; |
| 378 local bare_jid = session.username.."@"..session.host; | 378 local bare_jid = session.username.."@"..session.host; |
| 379 local to = stanza.attr.to; | 379 local to = stanza.attr.to; |
| 380 local from = stanza.attr.from; | 380 local from = stanza.attr.from; |
| 381 | 381 |
| 382 local to_user = bare_jid == jid_bare(to); | 382 local is_to_user = bare_jid == jid_bare(to); |
| 383 local from_user = bare_jid == jid_bare(from); | 383 local is_from_user = bare_jid == jid_bare(from); |
| 384 | 384 |
| 385 module:log("debug", "stanza: %s, to: %s, from: %s", tostring(stanza.name), tostring(to), tostring(from)); | 385 module:log("debug", "stanza: %s, to: %s, from: %s", tostring(stanza.name), tostring(to), tostring(from)); |
| 386 | 386 |
| 387 if privacy_lists.lists == nil or | 387 if privacy_lists.lists == nil or |
| 388 (session.activePrivacyList == nil or session.activePrivacyList == "") and | 388 (session.activePrivacyList == nil or session.activePrivacyList == "") and |
| 389 (privacy_lists.default == nil or privacy_lists.default == "") | 389 (privacy_lists.default == nil or privacy_lists.default == "") |
| 390 then | 390 then |
| 391 return; -- Nothing to block, default is Allow all | 391 return; -- Nothing to block, default is Allow all |
| 392 end | 392 end |
| 393 if from_user and to_user then | 393 if is_from_user and is_to_user then |
| 394 module:log("debug", "Not blocking communications between user's resources"); | 394 module:log("debug", "Not blocking communications between user's resources"); |
| 395 return; -- from one of a user's resource to another => HANDS OFF! | 395 return; -- from one of a user's resource to another => HANDS OFF! |
| 396 end | 396 end |
| 397 | 397 |
| 398 local idx; | 398 local idx; |
| 416 local apply = false; | 416 local apply = false; |
| 417 local block = false; | 417 local block = false; |
| 418 if ( | 418 if ( |
| 419 (stanza.name == "message" and item.message) or | 419 (stanza.name == "message" and item.message) or |
| 420 (stanza.name == "iq" and item.iq) or | 420 (stanza.name == "iq" and item.iq) or |
| 421 (stanza.name == "presence" and to_user and item["presence-in"]) or | 421 (stanza.name == "presence" and is_to_user and item["presence-in"]) or |
| 422 (stanza.name == "presence" and from_user and item["presence-out"]) or | 422 (stanza.name == "presence" and is_from_user and item["presence-out"]) or |
| 423 (item.message == false and item.iq == false and item["presence-in"] == false and item["presence-out"] == false) | 423 (item.message == false and item.iq == false and item["presence-in"] == false and item["presence-out"] == false) |
| 424 ) then | 424 ) then |
| 425 apply = true; | 425 apply = true; |
| 426 end | 426 end |
| 427 if apply then | 427 if apply then |
| 428 local evilJid = {}; | 428 local evilJid = {}; |
| 429 apply = false; | 429 apply = false; |
| 430 if to_user then | 430 if is_to_user then |
| 431 module:log("debug", "evil jid is (from): %s", from); | 431 module:log("debug", "evil jid is (from): %s", from); |
| 432 evilJid.node, evilJid.host, evilJid.resource = jid_split(from); | 432 evilJid.node, evilJid.host, evilJid.resource = jid_split(from); |
| 433 else | 433 else |
| 434 module:log("debug", "evil jid is (to): %s", to); | 434 module:log("debug", "evil jid is (to): %s", to); |
| 435 evilJid.node, evilJid.host, evilJid.resource = jid_split(to); | 435 evilJid.node, evilJid.host, evilJid.resource = jid_split(to); |