diff options
author | Paweł Chmielowski <pchmielowski@process-one.net> | 2019-03-29 11:25:35 +0100 |
---|---|---|
committer | Paweł Chmielowski <pchmielowski@process-one.net> | 2019-03-29 11:25:35 +0100 |
commit | a7310ffea1292a6bc617843619d72d335971ed46 (patch) | |
tree | 09b5b3b2054026a54f02b8cadf2c1a156197cbcf | |
parent | Add option user_mucsub_from_muc_archive to mod_muc (diff) |
Make misc:add_delay_info properly handle multiple delay tags in element
-rw-r--r-- | rebar.config | 2 | ||||
-rw-r--r-- | src/misc.erl | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/rebar.config b/rebar.config index 00a49149b..c654f41e9 100644 --- a/rebar.config +++ b/rebar.config @@ -24,7 +24,7 @@ {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.1.0"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.15"}}}, {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.35"}}}, - {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.3.2"}}}, + {xmpp, ".*", {git, "https://github.com/processone/xmpp", "472ed4e5ce5c3a9fff0778c7844c287356babc20"}}, {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.18"}}}, {jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}}, {p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.4"}}}, diff --git a/src/misc.erl b/src/misc.erl index 8cca30d5d..1b7fc22c1 100644 --- a/src/misc.erl +++ b/src/misc.erl @@ -59,16 +59,18 @@ add_delay_info(Stz, From, Time) -> -spec add_delay_info(stanza(), jid(), erlang:timestamp(), binary()) -> stanza(). add_delay_info(Stz, From, Time, Desc) -> - NewDelay = #delay{stamp = Time, from = From, desc = Desc}, - case xmpp:get_subtag(Stz, #delay{stamp = {0,0,0}}) of - #delay{from = OldFrom} when is_record(OldFrom, jid) -> - case jid:tolower(From) == jid:tolower(OldFrom) of - true -> - Stz; - false -> - xmpp:append_subtags(Stz, [NewDelay]) - end; + Delays = xmpp:get_all_subtags(Stz, #delay{stamp = {0,0,0}}), + Matching = lists:any( + fun(#delay{from = OldFrom}) when is_record(OldFrom, jid) -> + jid:tolower(From) == jid:tolower(OldFrom); + (_) -> + false + end, Delays), + case Matching of + true -> + Stz; _ -> + NewDelay = #delay{stamp = Time, from = From, desc = Desc}, xmpp:append_subtags(Stz, [NewDelay]) end. |