comparison mod_archive/mod_archive.lua @ 737:e4ea03b060ed

mod_archive: switch from/to The XEP-0136 is not very explicit about the meening of <from> and <to> elements, but the examples are clear: <from> means it comes from the user in the 'with' attribute of the collection. That is the opposite of what is currently implemented in that module. So for better compatibility with complient clients, this switch the 'from' and 'to' fields
author Olivier Goffart <ogoffart@woboq.com>
date Wed, 04 Jul 2012 14:08:43 +0200
parents b031831b2ac0
children 9d5731af2c27
comparison
equal deleted inserted replaced
736:b031831b2ac0 737:e4ea03b060ed
85 local function store_msg(msg, node, host, isfrom) 85 local function store_msg(msg, node, host, isfrom)
86 local body = msg:child_with_name("body"); 86 local body = msg:child_with_name("body");
87 local thread = msg:child_with_name("thread"); 87 local thread = msg:child_with_name("thread");
88 local data = dm.list_load(node, host, ARCHIVE_DIR); 88 local data = dm.list_load(node, host, ARCHIVE_DIR);
89 local tag = isfrom and "from" or "to"; 89 local tag = isfrom and "from" or "to";
90 local with = isfrom and msg.attr.to or msg.attr.from; 90 local with = isfrom and msg.attr.from or msg.attr.to;
91 local utc_datetime = date_time(); 91 local utc_datetime = date_time();
92 local utc_secs = date_parse(utc_datetime); 92 local utc_secs = date_parse(utc_datetime);
93 if data then 93 if data then
94 -- The collection list are in REVERSE chronological order 94 -- The collection list are in REVERSE chronological order
95 for k, v in ipairs(data) do 95 for k, v in ipairs(data) do
757 757
758 return nil; 758 return nil;
759 end 759 end
760 760
761 local function message_handler(data) 761 local function message_handler(data)
762 msg_handler(data, data.stanza.attr.to, data.stanza.attr.from, false) 762 msg_handler(data, data.stanza.attr.to, data.stanza.attr.from, true)
763 end 763 end
764 764
765 local function premessage_handler(data) 765 local function premessage_handler(data)
766 msg_handler(data, data.stanza.attr.from, data.stanza.attr.to, true) 766 msg_handler(data, data.stanza.attr.from, data.stanza.attr.to, false)
767 end 767 end
768 768
769 -- Preferences 769 -- Preferences
770 module:hook("iq/self/urn:xmpp:archive:pref", preferences_handler); 770 module:hook("iq/self/urn:xmpp:archive:pref", preferences_handler);
771 module:hook("iq/self/urn:xmpp:archive:itemremove", itemremove_handler); 771 module:hook("iq/self/urn:xmpp:archive:itemremove", itemremove_handler);