diff --git a/ChangeLog b/ChangeLog index d2677841d..4c977bb1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,11 @@ * src/ejabberd_ctl.erl: Now prints a user-friendly when trying to restore a backup from a non-existent file. + + * src/ejabberd_ctl.erl: Added a way to delete the older message + from the offline message table. This function is only available if + offline message queue is stored in Mnesia internal database. The + function delete_old_messages is not available in mod_offline_odbc. 2006-05-01 Mickael Remond diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index bdadc3827..1d929c002 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -175,6 +175,21 @@ process(["delete-expired-messages"]) -> mod_offline:remove_expired_messages(), ?STATUS_SUCCESS; +process(["delete-old-messages", Days]) -> + case catch list_to_integer(Days) of + {'EXIT',{Reason, _Stack}} -> + io:format("Can't delete old messages (~p). Please pass an integer as parameter.~n", + [Reason]), + ?STATUS_ERROR; + Integer when Integer >= 0 -> + {atomic, _} = mod_offline:remove_old_messages(Integer), + io:format("Removed messages older than ~s days~n", [Days]), + ?STATUS_SUCCESS; + Integer -> + io:format("Can't delete old messages. Please pass a positive integer as parameter.~n", []), + ?STATUS_ERROR + end; + process(["vhost", H | Args]) -> case jlib:nameprep(H) of false -> @@ -217,6 +232,7 @@ print_usage() -> {"import-file file", "import user data from jabberd 1.4 spool file"}, {"import-dir dir", "import user data from jabberd 1.4 spool directory"}, {"delete-expired-messages", "delete expired offline messages from database"}, + {"delete-old-messages n", "delete offline messages older than n days from database"}, {"vhost host ...", "execute host-specific commands"}] ++ ets:tab2list(ejabberd_ctl_cmds), MaxCmdLen =