Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-05-20 22:36:32 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-05-20 22:36:32 +0300
commit35d19b32f40a4f6aedecca36c3145ab3013ecf87 (patch)
tree2d724e209978999b79fe69be9d0be679cf4fb559 /src/mod_blocking_riak.erl
parent654d907dcfed85403c4a45070e093287ffe54328 (diff)
Implement cache for mod_privacy/mod_blocking
Diffstat (limited to 'src/mod_blocking_riak.erl')
-rw-r--r--src/mod_blocking_riak.erl113
1 files changed, 0 insertions, 113 deletions
diff --git a/src/mod_blocking_riak.erl b/src/mod_blocking_riak.erl
deleted file mode 100644
index 307cd8744..000000000
--- a/src/mod_blocking_riak.erl
+++ /dev/null
@@ -1,113 +0,0 @@
-%%%-------------------------------------------------------------------
-%%% File : mod_blocking_riak.erl
-%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net>
-%%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net>
-%%%
-%%%
-%%% ejabberd, Copyright (C) 2002-2017 ProcessOne
-%%%
-%%% This program is free software; you can redistribute it and/or
-%%% modify it under the terms of the GNU General Public License as
-%%% published by the Free Software Foundation; either version 2 of the
-%%% License, or (at your option) any later version.
-%%%
-%%% This program is distributed in the hope that it will be useful,
-%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
-%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-%%% General Public License for more details.
-%%%
-%%% You should have received a copy of the GNU General Public License along
-%%% with this program; if not, write to the Free Software Foundation, Inc.,
-%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-%%%
-%%%----------------------------------------------------------------------
-
--module(mod_blocking_riak).
-
--behaviour(mod_blocking).
-
-%% API
--export([process_blocklist_block/3, unblock_by_filter/3,
- process_blocklist_get/2]).
-
--include("mod_privacy.hrl").
-
-%%%===================================================================
-%%% API
-%%%===================================================================
-process_blocklist_block(LUser, LServer, Filter) ->
- {atomic,
- begin
- case ejabberd_riak:get(privacy, mod_privacy_riak:privacy_schema(),
- {LUser, LServer}) of
- {ok, #privacy{default = Default, lists = Lists} = P} ->
- case lists:keysearch(Default, 1, Lists) of
- {value, {_, List}} ->
- NewDefault = Default,
- NewLists1 = lists:keydelete(Default, 1, Lists);
- false ->
- NewDefault = <<"Blocked contacts">>,
- NewLists1 = Lists,
- List = []
- end;
- {error, _} ->
- P = #privacy{us = {LUser, LServer}},
- NewDefault = <<"Blocked contacts">>,
- NewLists1 = [],
- List = []
- end,
- NewList = Filter(List),
- NewLists = [{NewDefault, NewList} | NewLists1],
- case ejabberd_riak:put(P#privacy{default = NewDefault,
- lists = NewLists},
- mod_privacy_riak:privacy_schema()) of
- ok ->
- {ok, NewDefault, NewList};
- Err ->
- Err
- end
- end}.
-
-unblock_by_filter(LUser, LServer, Filter) ->
- {atomic,
- case ejabberd_riak:get(privacy, mod_privacy_riak:privacy_schema(),
- {LUser, LServer}) of
- {error, _} ->
- %% No lists, nothing to unblock
- ok;
- {ok, #privacy{default = Default, lists = Lists} = P} ->
- case lists:keysearch(Default, 1, Lists) of
- {value, {_, List}} ->
- NewList = Filter(List),
- NewLists1 = lists:keydelete(Default, 1, Lists),
- NewLists = [{Default, NewList} | NewLists1],
- case ejabberd_riak:put(P#privacy{lists = NewLists},
- mod_privacy_riak:privacy_schema()) of
- ok ->
- {ok, Default, NewList};
- Err ->
- Err
- end;
- false ->
- %% No default list, nothing to unblock
- ok
- end
- end}.
-
-process_blocklist_get(LUser, LServer) ->
- case ejabberd_riak:get(privacy, mod_privacy_riak:privacy_schema(),
- {LUser, LServer}) of
- {ok, #privacy{default = Default, lists = Lists}} ->
- case lists:keysearch(Default, 1, Lists) of
- {value, {_, List}} -> List;
- _ -> []
- end;
- {error, notfound} ->
- [];
- {error, _} ->
- error
- end.
-
-%%%===================================================================
-%%% Internal functions
-%%%===================================================================