From 45b366775ee4ecb985b48feea9d1976f030dffc1 Mon Sep 17 00:00:00 2001 From: Aleksander Lisiecki Date: Wed, 8 May 2019 09:27:51 +0200 Subject: [PATCH] Implement retreive for mod_private_mysql --- src/mod_private.erl | 4 ++-- src/mod_private_mysql.erl | 7 +++++++ src/mod_private_rdbms.erl | 8 +------- src/rdbms/rdbms_queries.erl | 7 +++++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/mod_private.erl b/src/mod_private.erl index 2d63faa9c1c..db3175a57f2 100644 --- a/src/mod_private.erl +++ b/src/mod_private.erl @@ -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()}]. diff --git a/src/mod_private_mysql.erl b/src/mod_private_mysql.erl index dad88d4ccc9..56eb15ad4cf 100644 --- a/src/mod_private_mysql.erl +++ b/src/mod_private_mysql.erl @@ -9,6 +9,8 @@ multi_get_data/3, remove_user/2]). +-export([get_all_nss/2]). + -include("mongoose.hrl"). -include("jlib.hrl"). @@ -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. diff --git a/src/mod_private_rdbms.erl b/src/mod_private_rdbms.erl index 781e390b518..a433ba68927 100644 --- a/src/mod_private_rdbms.erl +++ b/src/mod_private_rdbms.erl @@ -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) -> diff --git a/src/rdbms/rdbms_queries.erl b/src/rdbms/rdbms_queries.erl index 27e2ab6d496..0fe0cab738b 100644 --- a/src/rdbms/rdbms_queries.erl +++ b/src/rdbms/rdbms_queries.erl @@ -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, @@ -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,