Mercurial > prosody-modules
comparison mod_delay/mod_delay.lua @ 2435:05248d5a7166
mod_delay: Only add delay to messages of type chat or groupchat (fixes #811)
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Sun, 08 Jan 2017 06:26:21 +0100 |
parents | 3b2c94ea0c2e |
children | 5e94061c1aa7 |
comparison
equal
deleted
inserted
replaced
2434:a43242289fce | 2435:05248d5a7166 |
---|---|
9 error(module.name.." should NOT be loaded as a component, check out http://prosody.im/doc/components", 0); | 9 error(module.name.." should NOT be loaded as a component, check out http://prosody.im/doc/components", 0); |
10 end | 10 end |
11 | 11 |
12 local add_delay = function(stanza, session) | 12 local add_delay = function(stanza, session) |
13 if stanza and stanza.name == "message" and stanza:get_child("delay", xmlns_delay) == nil then | 13 if stanza and stanza.name == "message" and stanza:get_child("delay", xmlns_delay) == nil then |
14 -- session.log("debug", "adding delay to message %s", tostring(stanza)); | 14 -- only add delay tag to chat or groupchat messages (should we add a delay to anything else, too???) |
15 stanza = stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); | 15 if stanza.attr.type == "chat" or stanza.attr.type == "groupchat" then |
16 -- session.log("debug", "adding delay to message %s", tostring(stanza)); | |
17 stanza = stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); | |
18 end | |
16 end | 19 end |
17 return stanza; | 20 return stanza; |
18 end | 21 end |
19 | 22 |
20 module:hook("resource-bind", function(event) | 23 module:hook("resource-bind", function(event) |