diff options
author | Robert Hoelz <rob@hoelz.ro> | 2010-12-09 12:23:37 -0600 |
---|---|---|
committer | Robert Hoelz <rob@hoelz.ro> | 2010-12-09 12:23:37 -0600 |
commit | de4b6ceb3376974f56d80129848d5fd0c0009bd7 (patch) | |
tree | 97189181cdd2630cbe40ac75c03ce17f7244c448 | |
parent | 109b7a0e12503d943574cf1150a92f903146a2ac (diff) | |
download | prosody-de4b6ceb3376974f56d80129848d5fd0c0009bd7.tar.gz prosody-de4b6ceb3376974f56d80129848d5fd0c0009bd7.zip |
core.offlinemanager, mod_message, mod_presence: Removed core.offlinemanager in favor of mod_offline.
-rw-r--r-- | core/offlinemanager.lua | 41 | ||||
-rw-r--r-- | plugins/mod_message.lua | 7 | ||||
-rw-r--r-- | plugins/mod_presence.lua | 11 |
3 files changed, 8 insertions, 51 deletions
diff --git a/core/offlinemanager.lua b/core/offlinemanager.lua deleted file mode 100644 index 97781e82..00000000 --- a/core/offlinemanager.lua +++ /dev/null @@ -1,41 +0,0 @@ --- Prosody IM --- Copyright (C) 2008-2010 Matthew Wild --- Copyright (C) 2008-2010 Waqas Hussain --- --- This project is MIT/X11 licensed. Please see the --- COPYING file in the source package for more information. --- - - -
-local datamanager = require "util.datamanager";
-local st = require "util.stanza";
-local datetime = require "util.datetime";
-local ipairs = ipairs;
-
-module "offlinemanager"
-
-function store(node, host, stanza)
- stanza.attr.stamp = datetime.datetime();
- stanza.attr.stamp_legacy = datetime.legacy();
- return datamanager.list_append(node, host, "offline", st.preserialize(stanza));
-end
-
-function load(node, host)
- local data = datamanager.list_load(node, host, "offline");
- if not data then return; end
- for k, v in ipairs(data) do
- local stanza = st.deserialize(v);
- stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203
- stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)
- stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
- data[k] = stanza;
- end
- return data;
-end
-
-function deleteAll(node, host)
- return datamanager.list_store(node, host, "offline", nil);
-end
-
-return _M;
diff --git a/plugins/mod_message.lua b/plugins/mod_message.lua index e38b60e6..6ac23ab2 100644 --- a/plugins/mod_message.lua +++ b/plugins/mod_message.lua @@ -14,7 +14,6 @@ local st = require "util.stanza"; local jid_bare = require "util.jid".bare; local jid_split = require "util.jid".split; local user_exists = require "core.usermanager".user_exists; -local offlinemanager = require "core.offlinemanager"; local t_insert = table.insert; local function process_to_bare(bare, origin, stanza) @@ -47,7 +46,11 @@ local function process_to_bare(bare, origin, stanza) local node, host = jid_split(bare); if user_exists(node, host) then -- TODO apply the default privacy list - offlinemanager.store(node, host, stanza); + + module:fire_event('message/offline/store', { + origin = origin, + stanza = stanza, + }); else origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); end diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 65abe665..933aac62 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -22,7 +22,6 @@ local NULL = {}; local rostermanager = require "core.rostermanager"; local sessionmanager = require "core.sessionmanager"; -local offlinemanager = require "core.offlinemanager"; local function select_top_resources(user) local priority = 0; @@ -116,13 +115,9 @@ function handle_normal_presence(origin, stanza) end if priority >= 0 then - local offline = offlinemanager.load(node, host); - if offline then - for _, msg in ipairs(offline) do - origin.send(msg); -- FIXME do we need to modify to/from in any way? - end - offlinemanager.deleteAll(node, host); - end + local event = { origin = origin } + module:fire_event('message/offline/broadcast', event); + module:fire_event('message/offline/delete', event); end end if stanza.attr.type == "unavailable" then |