summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2016-08-13 00:07:27 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2016-08-13 00:07:27 +0200
commit4ee8af633bc1d14059ae22a591e7c7db7098c6e4 (patch)
tree9f6e6e152f9ca29c661b631d8946703c2e77678b
parentHonor <store/> hint for any non-"error" message (diff)
Store announcements for offline users
Add a <store/> hint to announcements (unless they are explicitly sent to online users). Without that hint, announcements weren't delivered to offline users, since they are sent as messages of type "headline".
Diffstat (limited to '')
-rw-r--r--src/mod_announce.erl12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mod_announce.erl b/src/mod_announce.erl
index 52ff2de9..d74c46bf 100644
--- a/src/mod_announce.erl
+++ b/src/mod_announce.erl
@@ -696,7 +696,7 @@ announce_all(From, To, Packet) ->
lists:foreach(
fun({User, Server}) ->
Dest = jid:make(User, Server, <<>>),
- ejabberd_router:route(Local, Dest, Packet)
+ ejabberd_router:route(Local, Dest, add_store_hint(Packet))
end, ejabberd_auth:get_vh_registered_users(Host))
end.
@@ -713,7 +713,7 @@ announce_all_hosts_all(From, To, Packet) ->
lists:foreach(
fun({User, Server}) ->
Dest = jid:make(User, Server, <<>>),
- ejabberd_router:route(Local, Dest, Packet)
+ ejabberd_router:route(Local, Dest, add_store_hint(Packet))
end, ejabberd_auth:dirty_get_registered_users())
end.
@@ -899,7 +899,7 @@ send_announcement_to_all(Host, SubjectS, BodyS) ->
lists:foreach(
fun({U, S, R}) ->
Dest = jid:make(U, S, R),
- ejabberd_router:route(Local, Dest, Packet)
+ ejabberd_router:route(Local, Dest, add_store_hint(Packet))
end, Sessions).
-spec get_access(global | binary()) -> atom().
@@ -909,6 +909,12 @@ get_access(Host) ->
fun(A) -> A end,
none).
+-spec add_store_hint(xmlel()) -> xmlel().
+
+add_store_hint(El) ->
+ Hint = #xmlel{name = <<"store">>, attrs = [{<<"xmlns">>, ?NS_HINTS}]},
+ fxml:append_subtags(El, [Hint]).
+
%%-------------------------------------------------------------------------
export(LServer) ->
Mod = gen_mod:db_mod(LServer, ?MODULE),