diff --git a/big_tests/tests/privacy_SUITE.erl b/big_tests/tests/privacy_SUITE.erl index fce516c797..606ce0d0c3 100644 --- a/big_tests/tests/privacy_SUITE.erl +++ b/big_tests/tests/privacy_SUITE.erl @@ -42,7 +42,8 @@ groups() -> ct_helper:repeat_all_until_all_ok(G). management_test_cases() -> - [discovering_support, + [ + discover_support, get_all_lists, get_existing_list, get_many_lists, @@ -159,13 +160,11 @@ end_per_testcase(CaseName, Config) -> %% or block all of them, when the item has no children %% - blocking: messages, presence (in/out), iqs, all -discovering_support(Config) -> +discover_support(Config) -> escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> Server = escalus_client:server(Alice), IqGet = escalus_stanza:disco_info(Server), - escalus_client:send(Alice, IqGet), - Result = escalus_client:wait_for_stanza(Alice), - escalus:assert(is_iq_result, [IqGet], Result), + Result = escalus:send_iq_and_wait_for_result(Alice, IqGet), escalus:assert(has_feature, [?NS_PRIVACY], Result) end). @@ -867,16 +866,19 @@ subscribe_from_to(From, To, IsSecondSubscription) -> ToBareJid = escalus_utils:get_short_jid(To), SubStanza = escalus_stanza:presence_direct(ToBareJid, <<"subscribe">>), escalus_client:send(From, SubStanza), - escalus_client:wait_for_stanza(From), - escalus_client:wait_for_stanza(To), + PushReq = escalus_client:wait_for_stanza(From), + escalus:assert(is_roster_set, PushReq), + Received = escalus_client:wait_for_stanza(To), %% To accepts From FromBareJid = escalus_utils:get_short_jid(From), SubConfirmStanza = escalus_stanza:presence_direct(FromBareJid, <<"subscribed">>), escalus_client:send(To, SubConfirmStanza), case IsSecondSubscription of true -> + escalus:assert(is_roster_set, Received), escalus_client:wait_for_stanzas(To, 2); false -> + escalus:assert(is_presence_with_type, [<<"subscribe">>], Received), escalus_client:wait_for_stanza(To) end, escalus_client:wait_for_stanzas(From, 3). diff --git a/include/mod_privacy.hrl b/include/mod_privacy.hrl index 6a870a747c..aaf8a5fffa 100644 --- a/include/mod_privacy.hrl +++ b/include/mod_privacy.hrl @@ -19,9 +19,9 @@ %%%---------------------------------------------------------------------- -record(privacy, { - us :: jid:simple_bare_jid(), + us :: jid:simple_bare_jid(), default = none :: mod_privacy:list_name(), - lists = [] :: [{mod_privacy:list_name(), mod_privacy:list_item()}] + lists = [] :: [{mod_privacy:list_name(), mod_privacy:list_item()}] }). -record(listitem, { @@ -37,7 +37,7 @@ }). -record(userlist, { - name = none :: mod_privacy:list_name(), - list = [] :: [mod_privacy:list_item()], + name = none :: mod_privacy:list_name(), + list = [] :: [mod_privacy:list_item()], needdb = false :: boolean() }). diff --git a/priv/mssql2012.sql b/priv/mssql2012.sql index d0183429cc..0f537e7a60 100644 --- a/priv/mssql2012.sql +++ b/priv/mssql2012.sql @@ -186,7 +186,7 @@ CREATE TABLE [dbo].[privacy_default_list]( [name] [nvarchar](250) NOT NULL, CONSTRAINT [PK_privacy_default_list_username] PRIMARY KEY CLUSTERED ( - [server] ASC, [username] ASC + [server], [username] )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] diff --git a/priv/mysql.sql b/priv/mysql.sql index 051fbc2727..1e1653e00a 100644 --- a/priv/mysql.sql +++ b/priv/mysql.sql @@ -139,8 +139,8 @@ CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname); CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit); CREATE TABLE privacy_default_list ( - server varchar(250), - username varchar(250), + server varchar(250) NOT NULL, + username varchar(250) NOT NULL, name varchar(250) NOT NULL, PRIMARY KEY (server, username) ) CHARACTER SET utf8mb4 diff --git a/priv/pg.sql b/priv/pg.sql index 83edb4f59e..797266857f 100644 --- a/priv/pg.sql +++ b/priv/pg.sql @@ -130,7 +130,7 @@ CREATE TABLE privacy_default_list ( server varchar(250), username varchar(250), name text NOT NULL, - PRIMARY KEY (server,username) + PRIMARY KEY (server, username) ); CREATE TABLE privacy_list ( @@ -139,7 +139,7 @@ CREATE TABLE privacy_list ( name text NOT NULL, id SERIAL UNIQUE, created_at TIMESTAMP NOT NULL DEFAULT now(), - PRIMARY KEY (server,username,name) + PRIMARY KEY (server, username, name) ); CREATE TABLE privacy_list_data ( diff --git a/rel/vars-toml.config.in b/rel/vars-toml.config.in index 7f55c3b741..36077eaa55 100644 --- a/rel/vars-toml.config.in +++ b/rel/vars-toml.config.in @@ -22,6 +22,7 @@ {mod_cache_users, ""}. % enabled, no options {mod_last, "[modules.mod_last]"}. {mod_offline, ""}. % enabled, no options +{mod_privacy, ""}. {mod_blocking, "[modules.mod_blocking]"}. {mod_private, "[modules.mod_private]"}. {mod_roster, ""}. % enabled, no options diff --git a/src/privacy/mod_privacy.erl b/src/privacy/mod_privacy.erl index 201df3e8b2..dc0d149022 100644 --- a/src/privacy/mod_privacy.erl +++ b/src/privacy/mod_privacy.erl @@ -86,18 +86,18 @@ -callback remove_user(HostType, LUser, LServer) -> any() when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(). + LUser :: jid:luser(), + LServer :: jid:lserver(). -callback remove_domain(HostType, LServer) -> any() when HostType :: mongooseim:host_type(), - LServer :: binary(). + LServer :: jid:lserver(). -callback get_list_names(HostType, LUser, LServer) -> {ok, {Default, Names}} | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Default :: list_name(), Names :: list(list_name()), Reason :: not_found | term(). @@ -105,8 +105,8 @@ -callback get_privacy_list(HostType, LUser, LServer, Name) -> {ok, Items} | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Name :: list_name(), Items :: list(list_item()), Reason :: not_found | term(). @@ -114,31 +114,31 @@ -callback set_default_list(HostType, LUser, LServer, Name) -> ok | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Name :: list_name(), Reason :: not_found | term(). -callback forget_default_list(HostType, LUser, LServer) -> ok | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Reason :: not_found | term(). -callback remove_privacy_list(HostType, LUser, LServer, Name) -> ok | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Name :: list_name(), Reason :: conflict | term(). -callback replace_privacy_list(HostType, LUser, LServer, Name, Items) -> ok | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Name :: list_name(), Items :: list(list_item()), Reason :: conflict | term(). @@ -146,8 +146,8 @@ -callback get_default_list(HostType, LUser, LServer) -> {ok, {Default, Items}} | {error, Reason} when HostType :: mongooseim:host_type(), - LUser :: binary(), - LServer :: binary(), + LUser :: jid:luser(), + LServer :: jid:lserver(), Default :: list_name(), Items :: list(list_item()), Reason :: not_found | term().