Software /
code /
prosody-modules
Diff
mod_archive_muc/mod_archive_muc.lua @ 238:5343b3ebaffb
mod_archive_muc: use usermanager to check if some user exists; use rostermanager to check if someone is in the roster; minor fixes.
author | shinysky<shinysky1986(AT)gmail.com> |
---|---|
date | Tue, 10 Aug 2010 08:58:57 +0800 |
parent | 237:d900be0dee3e |
child | 240:ef0b580f434d |
line wrap: on
line diff
--- a/mod_archive_muc/mod_archive_muc.lua Mon Aug 09 18:45:51 2010 +0800 +++ b/mod_archive_muc/mod_archive_muc.lua Tue Aug 10 08:58:57 2010 +0800 @@ -9,12 +9,12 @@ local dm = require "util.datamanager"; local jid = require "util.jid"; local datetime = require "util.datetime"; +local um = require "core.usermanager"; +local rom = require "core.rostermanager"; local PREFS_DIR = "archive_muc_prefs"; local ARCHIVE_DIR = "archive_muc"; -local HOST = 'localhost'; - local AUTO_ARCHIVING_ENABLED = true; module:add_feature("urn:xmpp:archive#preferences"); @@ -31,9 +31,7 @@ dm.store(node, host, PREFS_DIR, st.preserialize(data)); end -local function date_time(localtime) - return datetime.datetime(localtime); -end +local date_time = datetime.datetime; local function match_jid(rule, id) return not rule or jid.compare(id, rule); @@ -123,9 +121,8 @@ return false; end -local function is_in_roster(node, host, jid) - -- TODO - return true; +local function is_in_roster(node, host, id) + return rom.is_contact_subscribed(node, host, jid.bare(id)); end local function apply_pref(node, host, jid) @@ -166,11 +163,10 @@ if body then local from_node, from_host = jid.split(stanza.attr.from); local to_node, to_host = jid.split(stanza.attr.to); - -- FIXME only archive messages of users on this host - if from_host == HOST and apply_pref(from_node, from_host, stanza.attr.to) then + if um.user_exists(from_node, from_host) and apply_pref(from_node, from_host, stanza.attr.to) then store_msg(stanza, from_node, from_host); end - if to_host == HOST and apply_pref(to_node, to_host, stanza.attr.from) then + if um.user_exists(to_node, to_host) and apply_pref(to_node, to_host, stanza.attr.from) then store_msg(stanza, to_node, to_host); end end @@ -183,7 +179,6 @@ -- Archive management module:hook("iq/self/urn:xmpp:archive#management:query", management_handler); -module:hook("message/full", msg_handler, 20); module:hook("message/bare", msg_handler, 20); -- TODO prefs: [1] = "\n ";