Mercurial > prosody-hg
comparison plugins/mod_muc_mam.lua @ 8786:adffadd88ff0
mod_muc_mam: Have stanza-id filtering over all groupchat messages, not just ones considered for history
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 28 Apr 2018 00:47:08 +0200 |
| parents | 82b889608503 |
| children | a9c3b15b9d37 |
comparison
equal
deleted
inserted
replaced
| 8785:82b889608503 | 8786:adffadd88ff0 |
|---|---|
| 301 return history[i]; | 301 return history[i]; |
| 302 end | 302 end |
| 303 return true; | 303 return true; |
| 304 end, 1); | 304 end, 1); |
| 305 | 305 |
| 306 module:hook("muc-broadcast-messages", function (event) | |
| 307 local room, stanza = event.room, event.stanza; | |
| 308 | |
| 309 -- Filter out <stanza-id> that claim to be from us | |
| 310 stanza:maptags(function (tag) | |
| 311 if tag.name == "stanza-id" and tag.attr.xmlns == xmlns_st_id | |
| 312 and jid_prep(tag.attr.by) == room.jid then | |
| 313 return nil; | |
| 314 end | |
| 315 if tag.name == "x" and tag.attr.xmlns == xmlns_muc_user then | |
| 316 return nil; | |
| 317 end | |
| 318 return tag; | |
| 319 end); | |
| 320 | |
| 321 end, 0); | |
| 322 | |
| 306 -- Handle messages | 323 -- Handle messages |
| 307 local function save_to_history(self, stanza) | 324 local function save_to_history(self, stanza) |
| 308 local room_node, room_host = jid_split(self.jid); | 325 local room_node, room_host = jid_split(self.jid); |
| 309 | |
| 310 -- Filter out <stanza-id> that claim to be from us | |
| 311 stanza:maptags(function (tag) | |
| 312 if tag.name == "stanza-id" and tag.attr.xmlns == xmlns_st_id | |
| 313 and jid_prep(tag.attr.by) == self.jid then | |
| 314 return nil; | |
| 315 end | |
| 316 if tag.name == "x" and tag.attr.xmlns == xmlns_muc_user then | |
| 317 return nil; | |
| 318 end | |
| 319 return tag; | |
| 320 end); | |
| 321 | 326 |
| 322 local stored_stanza = stanza; | 327 local stored_stanza = stanza; |
| 323 | 328 |
| 324 if stanza.name == "message" and self:get_whois() == "anyone" then | 329 if stanza.name == "message" and self:get_whois() == "anyone" then |
| 325 stored_stanza = st.clone(stanza); | 330 stored_stanza = st.clone(stanza); |
