25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Support floating point message/presence intervals

Let mod_muc support floating point values for "min_message_interval" and
"min_presence_interval", as documented in the guide.
This commit is contained in:
Holger Weiss 2014-11-15 22:35:56 +01:00
parent d5ecd32cec
commit 3b96525550

View File

@ -174,7 +174,7 @@ normal_state({route, From, <<"">>,
Now = now_to_usec(now()), Now = now_to_usec(now()),
MinMessageInterval = MinMessageInterval =
trunc(gen_mod:get_module_opt(StateData#state.server_host, trunc(gen_mod:get_module_opt(StateData#state.server_host,
mod_muc, min_message_interval, fun(MMI) when is_integer(MMI) -> MMI end, 0) mod_muc, min_message_interval, fun(MMI) when is_number(MMI) -> MMI end, 0)
* 1000000), * 1000000),
Size = element_size(Packet), Size = element_size(Packet),
{MessageShaper, MessageShaperInterval} = {MessageShaper, MessageShaperInterval} =
@ -1517,15 +1517,17 @@ get_user_activity(JID, StateData) ->
store_user_activity(JID, UserActivity, StateData) -> store_user_activity(JID, UserActivity, StateData) ->
MinMessageInterval = MinMessageInterval =
gen_mod:get_module_opt(StateData#state.server_host, trunc(gen_mod:get_module_opt(StateData#state.server_host,
mod_muc, min_message_interval, mod_muc, min_message_interval,
fun(I) when is_integer(I), I>=0 -> I end, fun(I) when is_number(I), I>=0 -> I end,
0), 0)
* 1000),
MinPresenceInterval = MinPresenceInterval =
gen_mod:get_module_opt(StateData#state.server_host, trunc(gen_mod:get_module_opt(StateData#state.server_host,
mod_muc, min_presence_interval, mod_muc, min_presence_interval,
fun(I) when is_integer(I), I>=0 -> I end, fun(I) when is_number(I), I>=0 -> I end,
0), 0)
* 1000),
Key = jlib:jid_tolower(JID), Key = jlib:jid_tolower(JID),
Now = now_to_usec(now()), Now = now_to_usec(now()),
Activity1 = clean_treap(StateData#state.activity, Activity1 = clean_treap(StateData#state.activity,
@ -1556,8 +1558,8 @@ store_user_activity(JID, UserActivity, StateData) ->
100000), 100000),
Delay = lists:max([MessageShaperInterval, Delay = lists:max([MessageShaperInterval,
PresenceShaperInterval, PresenceShaperInterval,
MinMessageInterval * 1000, MinMessageInterval,
MinPresenceInterval * 1000]) MinPresenceInterval])
* 1000, * 1000,
Priority = {1, -(Now + Delay)}, Priority = {1, -(Now + Delay)},
StateData#state{activity = StateData#state{activity =