Software /
code /
prosody-modules
Comparison
mod_mam/mod_mam.lua @ 1150:296820f18ba6
mod_mam: Add support for XEP-0334: Message Processing Hints
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 11 Aug 2013 23:23:58 +0200 |
parent | 1149:d055c44a7f61 |
child | 1152:01fa82074b62 |
comparison
equal
deleted
inserted
replaced
1149:d055c44a7f61 | 1150:296820f18ba6 |
---|---|
178 local orig_type = stanza.attr.type or "normal"; | 178 local orig_type = stanza.attr.type or "normal"; |
179 local orig_from = stanza.attr.from; | 179 local orig_from = stanza.attr.from; |
180 local orig_to = stanza.attr.to or orig_from; | 180 local orig_to = stanza.attr.to or orig_from; |
181 -- Stanza without 'to' are treated as if it was to their own bare jid | 181 -- Stanza without 'to' are treated as if it was to their own bare jid |
182 | 182 |
183 -- Don't store messages of these types | 183 -- We don't store messages of these types |
184 if orig_type == "error" | 184 if orig_type == "error" |
185 or orig_type == "headline" | 185 or orig_type == "headline" |
186 or orig_type == "groupchat" | 186 or orig_type == "groupchat" |
187 or not stanza:get_child("body") then | 187 -- or that don't have a <body/> |
188 or not stanza:get_child("body") | |
189 -- or if hints suggest we shouldn't | |
190 or stanza:get_child("no-permanent-store", "urn:xmpp:hints") | |
191 or stanza:get_child("no-store", "urn:xmpp:hints") then | |
192 module:log("debug", "Not archiving stanza: %s (content)", stanza:top_tag()); | |
188 return; | 193 return; |
189 end | 194 end |
190 | 195 |
191 -- Whos storage do we put it in? | 196 -- Whos storage do we put it in? |
192 local store_user = c2s and origin.username or jid_split(orig_to); | 197 local store_user = c2s and origin.username or jid_split(orig_to); |
201 local ok, id = archive:append(store_user, time_now(), with, stanza); | 206 local ok, id = archive:append(store_user, time_now(), with, stanza); |
202 if ok and not c2s then | 207 if ok and not c2s then |
203 stanza:tag("archived", { xmlns = xmlns_mam, by = store_user.."@"..host, id = id }):up(); | 208 stanza:tag("archived", { xmlns = xmlns_mam, by = store_user.."@"..host, id = id }):up(); |
204 end | 209 end |
205 else | 210 else |
206 module:log("debug", "Not archiving stanza: %s", stanza:top_tag()); | 211 module:log("debug", "Not archiving stanza: %s (prefs)", stanza:top_tag()); |
207 end | 212 end |
208 end | 213 end |
209 | 214 |
210 local function c2s_message_handler(event) | 215 local function c2s_message_handler(event) |
211 return message_handler(event, true); | 216 return message_handler(event, true); |