Skip to content

Commit

Permalink
Implement retreive for mod_private_mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
aleklisi committed May 8, 2019
1 parent b5d3bc0 commit 45b3667
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/mod_private.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
%% gdpr callback
%%--------------------------------------------------------------------

-callback get_all_nss(LUser, LServer) -> NS when
-callback get_all_nss(LUser, LServer) -> NSs when
LUser :: binary(),
LServer :: binary(),
NS :: binary().
NSs :: [binary()].

-spec get_personal_data(jid:user(), jid:server()) ->
[{gdpr:data_group(), gdpr:schema(), gdpr:entries()}].
Expand Down
7 changes: 7 additions & 0 deletions src/mod_private_mysql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
multi_get_data/3,
remove_user/2]).

-export([get_all_nss/2]).

-include("mongoose.hrl").
-include("jlib.hrl").

Expand Down Expand Up @@ -52,3 +54,8 @@ select_value({NS, Def}, RowsDict) ->
remove_user(LUser, LServer) ->
SLUser = mongoose_rdbms:escape_string(LUser),
rdbms_queries:del_user_private_storage(LServer, SLUser).

get_all_nss(LUser, LServer) ->
{selected, Res} = rdbms_queries:get_all_roster_namespaces(LServer, LUser),
Keys = lists:map(fun({R}) -> R end, Res),
Keys.
8 changes: 1 addition & 7 deletions src/mod_private_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,8 @@ get_data(LUser, LServer, NS, Default) ->
end.

get_all_nss(LUser, LServer) ->
SLUser = mongoose_rdbms:escape_string(LUser),
lager:error("LUser = ~p\n", [LUser]),
lager:error("LServer = ~p\n", [LServer]),
{selected, Res} = mongoose_rdbms:sql_query(
LServer,
[<<"select namespace from private_storage where username=">>, mongoose_rdbms:use_escaped_string(SLUser)]),
{selected, Res} = rdbms_queries:get_all_roster_namespaces(LServer, LUser),
Keys = lists:map(fun({R}) -> R end, Res),
lager:error("Keys = ~p\n", [Keys]),
Keys.

remove_user(LUser, LServer) ->
Expand Down
7 changes: 7 additions & 0 deletions src/rdbms/rdbms_queries.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
get_subscription_t/3,
set_private_data/4,
set_private_data_sql/3,
get_all_roster_namespaces/2,
get_private_data/3,
multi_get_private_data/3,
multi_set_private_data/3,
Expand Down Expand Up @@ -641,6 +642,12 @@ set_private_data_sql(Username, LXMLNS, SData) ->
mongoose_rdbms:use_escaped_string(LXMLNS), ", ",
mongoose_rdbms:use_escaped_string(SData), ");"]].

get_all_roster_namespaces(LServer, Username) ->
mongoose_rdbms:sql_query(
LServer,
[<<"select namespace from private_storage where username=">>,
mongoose_rdbms:use_escaped_string(Username)]).

get_private_data(LServer, Username, LXMLNS) ->
mongoose_rdbms:sql_query(
LServer,
Expand Down

0 comments on commit 45b3667

Please sign in to comment.