Mercurial > prosody-modules
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_offline_hints/mod_offline_hints.lua Fri Mar 29 17:06:18 2019 +0100 @@ -0,0 +1,24 @@ +-- mod_offline_hints +-- +-- Copyright (C) 2019 Marcos de Vera Piquero <marcos.devera@quobis.com> +-- +-- This file is MIT/X11 licensed. +-- +-- A module to discard hinted messages with no-store at mod_offline +-- + +module:depends"offline"; + +local function handle_offline (event) + local stanza = event.stanza; + if (stanza:get_child("no-store", "urn:xmpp:hints") or + stanza:get_child("no-permanent-store", "urn:xmpp:hints")) then + module:log("debug", "Not storing offline stanza: %s (urn:xmpp:hints)", stanza); + return false; + end + return nil; +end + +module:hook("message/offline/handle", handle_offline); + +module:log("debug", "Module loaded");