Software /
code /
prosody
Comparison
plugins/mod_mam/mod_mam.lua @ 7844:316f5166eedb
mod_mam: Find out which party is the user and which is the 'with' earlier
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 19 Nov 2016 18:28:28 +0100 |
parent | 7843:04b09fd144eb |
child | 7845:eeb22f912577 |
comparison
equal
deleted
inserted
replaced
7843:04b09fd144eb | 7844:316f5166eedb |
---|---|
231 local orig_type = stanza.attr.type or "normal"; | 231 local orig_type = stanza.attr.type or "normal"; |
232 local orig_from = stanza.attr.from; | 232 local orig_from = stanza.attr.from; |
233 local orig_to = stanza.attr.to or orig_from; | 233 local orig_to = stanza.attr.to or orig_from; |
234 -- Stanza without 'to' are treated as if it was to their own bare jid | 234 -- Stanza without 'to' are treated as if it was to their own bare jid |
235 | 235 |
236 -- Whos storage do we put it in? | |
237 local store_user = c2s and origin.username or jid_split(orig_to); | |
238 -- And who are they chatting with? | |
239 local with = jid_bare(c2s and orig_to or orig_from); | |
240 | |
236 -- We store chat messages or normal messages that have a body | 241 -- We store chat messages or normal messages that have a body |
237 if not(orig_type == "chat" or (orig_type == "normal" and stanza:get_child("body")) ) then | 242 if not(orig_type == "chat" or (orig_type == "normal" and stanza:get_child("body")) ) then |
238 log("debug", "Not archiving stanza: %s (type)", stanza:top_tag()); | 243 log("debug", "Not archiving stanza: %s (type)", stanza:top_tag()); |
239 return; | 244 return; |
240 end | 245 end |
245 or stanza:get_child("no-store", "urn:xmpp:hints") then -- Hint telling us we should NOT store | 250 or stanza:get_child("no-store", "urn:xmpp:hints") then -- Hint telling us we should NOT store |
246 log("debug", "Not archiving stanza: %s (hint)", stanza:top_tag()); | 251 log("debug", "Not archiving stanza: %s (hint)", stanza:top_tag()); |
247 return; | 252 return; |
248 end | 253 end |
249 end | 254 end |
250 | |
251 -- Whos storage do we put it in? | |
252 local store_user = c2s and origin.username or jid_split(orig_to); | |
253 -- And who are they chatting with? | |
254 local with = jid_bare(c2s and orig_to or orig_from); | |
255 | 255 |
256 -- Check with the users preferences | 256 -- Check with the users preferences |
257 if shall_store(store_user, with) then | 257 if shall_store(store_user, with) then |
258 log("debug", "Archiving stanza: %s", stanza:top_tag()); | 258 log("debug", "Archiving stanza: %s", stanza:top_tag()); |
259 | 259 |