25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

mod_offline: Add 'store_offline_message' hook

The new 'store_offline_message' hook is invoked whenever an offline
message is stored.
This commit is contained in:
Holger Weiss 2016-08-15 22:30:08 +02:00
parent 4d19fb518f
commit 8821cf8b27

View File

@ -476,14 +476,22 @@ store_packet(From, To, Packet) ->
case check_event(From, To, Packet) of case check_event(From, To, Packet) of
true -> true ->
#jid{luser = LUser, lserver = LServer} = To, #jid{luser = LUser, lserver = LServer} = To,
TimeStamp = p1_time_compat:timestamp(), case ejabberd_hooks:run_fold(store_offline_message, LServer,
#xmlel{children = Els} = Packet, Packet, [From, To]) of
Expire = find_x_expire(TimeStamp, Els), drop ->
gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME) ! ok;
#offline_msg{us = {LUser, LServer}, NewPacket ->
timestamp = TimeStamp, expire = Expire, TimeStamp = p1_time_compat:timestamp(),
from = From, to = To, packet = Packet}, #xmlel{children = Els} = NewPacket,
stop; Expire = find_x_expire(TimeStamp, Els),
gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME) !
#offline_msg{us = {LUser, LServer},
timestamp = TimeStamp,
expire = Expire,
from = From, to = To,
packet = NewPacket},
stop
end;
_ -> ok _ -> ok
end; end;
false -> ok false -> ok