Comparison

plugins/mod_mam/mod_mam.lua @ 7892:f00943bbf84f

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Tue, 14 Feb 2017 23:42:11 +0100
parent 7891:01d2a2af3146
child 7901:fc859aed9279
comparison
equal deleted inserted replaced
7887:93fd15b5ec1b 7892:f00943bbf84f
10 -- 10 --
11 11
12 local xmlns_mam = "urn:xmpp:mam:1"; 12 local xmlns_mam = "urn:xmpp:mam:1";
13 local xmlns_delay = "urn:xmpp:delay"; 13 local xmlns_delay = "urn:xmpp:delay";
14 local xmlns_forward = "urn:xmpp:forward:0"; 14 local xmlns_forward = "urn:xmpp:forward:0";
15 local xmlns_st_id = "urn:xmpp:sid:0";
15 16
16 local um = require "core.usermanager"; 17 local um = require "core.usermanager";
17 local st = require "util.stanza"; 18 local st = require "util.stanza";
18 local rsm = require "util.rsm"; 19 local rsm = require "util.rsm";
19 local get_prefs = module:require"mamprefs".get; 20 local get_prefs = module:require"mamprefs".get;
246 -- And who are they chatting with? 247 -- And who are they chatting with?
247 local with = jid_bare(c2s and orig_to or orig_from); 248 local with = jid_bare(c2s and orig_to or orig_from);
248 249
249 -- Filter out <stanza-id> that claim to be from us 250 -- Filter out <stanza-id> that claim to be from us
250 stanza:maptags(function (tag) 251 stanza:maptags(function (tag)
251 if tag.name == "stanza-id" and tag.attr.xmlns == "urn:xmpp:sid:0" then 252 if tag.name == "stanza-id" and tag.attr.xmlns == xmlns_st_id then
252 local by_user, by_host, res = jid_prepped_split(tag.attr.by); 253 local by_user, by_host, res = jid_prepped_split(tag.attr.by);
253 if not res and by_host == module.host and by_user == store_user then 254 if not res and by_host == module.host and by_user == store_user then
254 return nil; 255 return nil;
255 end 256 end
256 end 257 end
291 log("debug", "Archiving stanza: %s", stanza:top_tag()); 292 log("debug", "Archiving stanza: %s", stanza:top_tag());
292 293
293 -- And stash it 294 -- And stash it
294 local ok, id = archive:append(store_user, nil, stanza, time_now(), with); 295 local ok, id = archive:append(store_user, nil, stanza, time_now(), with);
295 if ok then 296 if ok then
296 stanza:tag("stanza-id", { xmlns = "urn:xmpp:sid:0", by = store_user.."@"..host, id = id }):up(); 297 stanza:tag("stanza-id", { xmlns = xmlns_st_id, by = store_user.."@"..host, id = id }):up();
297 if cleanup then cleanup[store_user] = true; end 298 if cleanup then cleanup[store_user] = true; end
298 module:fire_event("archive-message-added", { origin = origin, stanza = stanza, for_user = store_user, id = id }); 299 module:fire_event("archive-message-added", { origin = origin, stanza = stanza, for_user = store_user, id = id });
299 end 300 end
300 else 301 else
301 log("debug", "Not archiving stanza: %s (prefs)", stanza:top_tag()); 302 log("debug", "Not archiving stanza: %s (prefs)", stanza:top_tag());
363 module:hook("message/bare", message_handler, 0); 364 module:hook("message/bare", message_handler, 0);
364 module:hook("message/full", message_handler, 0); 365 module:hook("message/full", message_handler, 0);
365 366
366 module:hook("account-disco-info", function(event) 367 module:hook("account-disco-info", function(event)
367 (event.reply or event.stanza):tag("feature", {var=xmlns_mam}):up(); 368 (event.reply or event.stanza):tag("feature", {var=xmlns_mam}):up();
369 (event.reply or event.stanza):tag("feature", {var=xmlns_st_id}):up();
368 end); 370 end);
369 371