Add function to delete all the emails in the queue
This commit is contained in:
parent
5e2462b7b2
commit
269813aa18
|
@ -17,7 +17,7 @@
|
|||
|
||||
%% API
|
||||
-export([start_link/0]).
|
||||
-export([queue/0]).
|
||||
-export([queue/0, empty_queue/0]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
|
@ -49,6 +49,16 @@ start_link() ->
|
|||
queue() ->
|
||||
gen_server:call(mailer, {queue_count}).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% Delete all the mails from the queue.
|
||||
%%
|
||||
%% @spec empty_queue() -> ok
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
empty_queue() ->
|
||||
gen_server:call(mailer, {empty_queue}).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
%%%===================================================================
|
||||
|
@ -93,7 +103,9 @@ init([]) ->
|
|||
handle_call({queue_count}, _From, State) ->
|
||||
Count = length(emails_to_send()),
|
||||
{reply, Count, State};
|
||||
|
||||
handle_call({empty_queue}, _From, State) ->
|
||||
remove_all_emails(),
|
||||
{reply, ok, State};
|
||||
handle_call(_Request, _From, State) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, State}.
|
||||
|
@ -266,6 +278,18 @@ remove_email(Id) ->
|
|||
end),
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
%% Remove all emails from the database.
|
||||
%%
|
||||
%% @spec remove_all_emails() -> void()
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
remove_all_emails() ->
|
||||
mnesia:clear_table(log_monitor_error),
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
%% @doc
|
||||
|
|
Loading…
Reference in New Issue
Block a user