Software /
code /
prosody
Changeset
3968:048af3ee5899
core.offlinemanager, mod_message, mod_presence: Removed core.offlinemanager in favor of mod_offline.
author | Robert Hoelz <rob@hoelz.ro> |
---|---|
date | Thu, 09 Dec 2010 12:23:37 -0600 |
parents | 3967:1a9bcbaeb55a |
children | 3969:32d4a73901e2 |
files | core/offlinemanager.lua plugins/mod_message.lua plugins/mod_presence.lua |
diffstat | 3 files changed, 8 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/core/offlinemanager.lua Mon Dec 27 06:10:34 2010 +0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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;
--- a/plugins/mod_message.lua Mon Dec 27 06:10:34 2010 +0500 +++ b/plugins/mod_message.lua Thu Dec 09 12:23:37 2010 -0600 @@ -14,7 +14,6 @@ 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 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
--- a/plugins/mod_presence.lua Mon Dec 27 06:10:34 2010 +0500 +++ b/plugins/mod_presence.lua Thu Dec 09 12:23:37 2010 -0600 @@ -22,7 +22,6 @@ 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 @@ 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