Software /
code /
prosody
Diff
plugins/mod_privacy.lua @ 5511:764bda4b28b8
Merge 0.9->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 23 Apr 2013 15:14:47 +0100 |
parent | 5500:eeea0eb2602a |
child | 5776:bd0ff8ae98a8 |
child | 6365:75bd55e84112 |
line wrap: on
line diff
--- a/plugins/mod_privacy.lua Fri Apr 19 13:30:37 2013 +0100 +++ b/plugins/mod_privacy.lua Tue Apr 23 15:14:47 2013 +0100 @@ -10,7 +10,6 @@ module:add_feature("jabber:iq:privacy"); local st = require "util.stanza"; -local datamanager = require "util.datamanager"; local bare_sessions, full_sessions = prosody.bare_sessions, prosody.full_sessions; local util_Jid = require "util.jid"; local jid_bare = util_Jid.bare; @@ -18,6 +17,8 @@ local load_roster = require "core.rostermanager".load_roster; local to_number = tonumber; +local privacy_storage = module:open_store(); + function isListUsed(origin, name, privacy_lists) local user = bare_sessions[origin.username.."@"..origin.host]; if user then @@ -217,7 +218,7 @@ if stanza.attr.to == nil then -- only service requests to own bare JID local query = stanza.tags[1]; -- the query element local valid = false; - local privacy_lists = datamanager.load(origin.username, origin.host, "privacy") or { lists = {} }; + local privacy_lists = privacy_storage:get(origin.username) or { lists = {} }; if privacy_lists.lists[1] then -- Code to migrate from old privacy lists format, remove in 0.8 module:log("info", "Upgrading format of stored privacy lists for %s@%s", origin.username, origin.host); @@ -272,7 +273,7 @@ end origin.send(st.error_reply(stanza, valid[1], valid[2], valid[3])); else - datamanager.store(origin.username, origin.host, "privacy", privacy_lists); + privacy_storage:set(origin.username, privacy_lists); end return true; end @@ -280,7 +281,7 @@ function checkIfNeedToBeBlocked(e, session) local origin, stanza = e.origin, e.stanza; - local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {}; + local privacy_lists = privacy_storage:get(session.username) or {}; local bare_jid = session.username.."@"..session.host; local to = stanza.attr.to or bare_jid; local from = stanza.attr.from;