Skip to content

Commit

Permalink
Apply review
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Jul 27, 2021
1 parent 7db8730 commit a9c7461
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 33 deletions.
16 changes: 9 additions & 7 deletions big_tests/tests/privacy_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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).
8 changes: 4 additions & 4 deletions include/mod_privacy.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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()
}).
2 changes: 1 addition & 1 deletion priv/mssql2012.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions priv/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions priv/pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions rel/vars-toml.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions src/privacy/mod_privacy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -86,68 +86,68 @@

-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().

-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().

-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().

-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().
Expand Down

0 comments on commit a9c7461

Please sign in to comment.