Mercurial > prosody-modules
comparison mod_offline_hints/mod_offline_hints.lua @ 3500:e86315c9b5c4
offline_hints: discard no-store hinted messages at mod_offline
This module will hook `message/offline/handle` and will skip offline
storage for messages hinted with `no-store` or `no-permanent-store`.
| author | marc0s <marcos.devera@quobis.com> |
|---|---|
| date | Fri, 29 Mar 2019 17:06:18 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3499:a1fc677d0cc8 | 3500:e86315c9b5c4 |
|---|---|
| 1 -- mod_offline_hints | |
| 2 -- | |
| 3 -- Copyright (C) 2019 Marcos de Vera Piquero <marcos.devera@quobis.com> | |
| 4 -- | |
| 5 -- This file is MIT/X11 licensed. | |
| 6 -- | |
| 7 -- A module to discard hinted messages with no-store at mod_offline | |
| 8 -- | |
| 9 | |
| 10 module:depends"offline"; | |
| 11 | |
| 12 local function handle_offline (event) | |
| 13 local stanza = event.stanza; | |
| 14 if (stanza:get_child("no-store", "urn:xmpp:hints") or | |
| 15 stanza:get_child("no-permanent-store", "urn:xmpp:hints")) then | |
| 16 module:log("debug", "Not storing offline stanza: %s (urn:xmpp:hints)", stanza); | |
| 17 return false; | |
| 18 end | |
| 19 return nil; | |
| 20 end | |
| 21 | |
| 22 module:hook("message/offline/handle", handle_offline); | |
| 23 | |
| 24 module:log("debug", "Module loaded"); |
