25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

* src/mod_offline.erl: Returns an error message to sender when

message is discarded due to quota (EJAB-314).

SVN Revision: 871
This commit is contained in:
Mickaël Rémond 2007-08-13 10:27:28 +00:00
parent 915d94b0dc
commit db957c4295
2 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2007-08-13 Mickael Remond <mickael.remond@process-one.net>
* src/mod_offline.erl: Returns an error message to sender when
message is discarded due to quota (EJAB-314).
2007-08-12 Mickael Remond <mickael.remond@process-one.net>
* src/odbc/ejabberd_odbc.erl: UTF-8 support for MySQL5 (EJAB-318).

View File

@ -31,7 +31,8 @@
%% TODO: Move this part as a module config file parameter:
%% Can be an integer > 0 or infinity:
-define(MAX_OFFLINE_MSGS, infinity).
%%-define(MAX_OFFLINE_MSGS, infinity).
-define(MAX_OFFLINE_MSGS, 5).
start(Host, _Opts) ->
mnesia:create_table(offline_msg,
@ -69,8 +70,7 @@ loop() ->
end,
if
Count > ?MAX_OFFLINE_MSGS ->
%% TODO: Warn that messages have been discarded
ok;
discard_warn_sender(Msgs);
true ->
if
Len >= ?OFFLINE_TABLE_LOCK_THRESHOLD ->
@ -405,3 +405,19 @@ update_table() ->
?INFO_MSG("Recreating offline_msg table", []),
mnesia:transform_table(offline_msg, ignore, Fields)
end.
%% Helper functions:
%% Warn senders that their messages have been discarded:
discard_warn_sender(Msgs) ->
lists:foreach(
fun(#offline_msg{from=From, to=To, packet=Packet}) ->
ErrText = "Your contact offline message queue is full. The message has been discarded.",
Lang = xml:get_tag_attr_s("xml:lang", Packet),
Err = jlib:make_error_reply(
Packet, ?ERRT_RESOURCE_CONSTRAINT(Lang, ErrText)),
ejabberd_router:route(
To,
From, Err)
end, Msgs).