Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored hook handlers in ejabberd_sm module #3763

Merged
merged 2 commits into from
Sep 20, 2022
Merged

Conversation

pawlooss1
Copy link
Member

This PR changes all hook handlers in ejabberd_sm module to gen_hook format.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 19, 2022

small_tests_24 / small_tests / 88d2d7e
Reports root / small


small_tests_25 / small_tests / 88d2d7e
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 88d2d7e
Reports root/ big
OK: 3607 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 88d2d7e
Reports root/ big
OK: 1968 / Failed: 0 / User-skipped: 555 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 88d2d7e
Reports root/ big
OK: 1968 / Failed: 0 / User-skipped: 555 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 88d2d7e
Reports root/ big
OK: 3607 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 88d2d7e
Reports root/ big
OK: 3581 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 88d2d7e
Reports root/ big
OK: 2089 / Failed: 0 / User-skipped: 434 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 88d2d7e
Reports root/ big
OK: 3981 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 88d2d7e
Reports root/ big
OK: 2429 / Failed: 0 / User-skipped: 429 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 88d2d7e
Reports root/ big
OK: 3981 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / 88d2d7e
Reports root/ big
OK: 3967 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 88d2d7e
Reports root/ big
OK: 3981 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 88d2d7e
Reports root/ big
OK: 2268 / Failed: 0 / User-skipped: 422 / Auto-skipped: 0


small_tests_24 / small_tests / 88d2d7e
Reports root / small


small_tests_25 / small_tests / 88d2d7e
Reports root / small

@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Base: 82.84% // Head: 82.81% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (0ba7a50) compared to base (ee45d84).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3763      +/-   ##
==========================================
- Coverage   82.84%   82.81%   -0.04%     
==========================================
  Files         531      531              
  Lines       34069    34083      +14     
==========================================
+ Hits        28226    28227       +1     
- Misses       5843     5856      +13     
Impacted Files Coverage Δ
src/ejabberd_sm.erl 86.88% <100.00%> (ø)
src/mongoose_hooks.erl 95.75% <100.00%> (+0.30%) ⬆️
src/event_pusher/mod_event_pusher_sns.erl 82.19% <0.00%> (-12.33%) ⬇️
src/elasticsearch/mongoose_elasticsearch.erl 76.92% <0.00%> (-7.70%) ⬇️
src/ejabberd.erl 55.00% <0.00%> (-5.00%) ⬇️
src/mam/mod_mam_muc_rdbms_arch_async.erl 82.85% <0.00%> (-2.86%) ⬇️
src/pubsub/node_pep.erl 77.77% <0.00%> (-1.86%) ⬇️
src/mam/mod_mam_elasticsearch_arch.erl 86.60% <0.00%> (-1.79%) ⬇️
src/global_distrib/mod_global_distrib_receiver.erl 79.51% <0.00%> (-1.21%) ⬇️
src/mod_muc_room.erl 78.45% <0.00%> (-0.23%) ⬇️
... and 4 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 19, 2022

small_tests_24 / small_tests / 0196a5d
Reports root / small


small_tests_25 / small_tests / 0196a5d
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 0196a5d
Reports root/ big
OK: 3607 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 0196a5d
Reports root/ big
OK: 1968 / Failed: 0 / User-skipped: 555 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 0196a5d
Reports root/ big
OK: 3607 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 0196a5d
Reports root/ big
OK: 3581 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 0196a5d
Reports root/ big
OK: 1968 / Failed: 0 / User-skipped: 555 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 0196a5d
Reports root/ big
OK: 3607 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 0196a5d
Reports root/ big
OK: 2089 / Failed: 0 / User-skipped: 434 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 0196a5d
Reports root/ big
OK: 3981 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 0196a5d
Reports root/ big
OK: 2429 / Failed: 0 / User-skipped: 429 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 0196a5d
Reports root/ big
OK: 3981 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 0196a5d
Reports root/ big
OK: 3981 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / 0196a5d
Reports root/ big
OK: 3967 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 0196a5d
Reports root/ big
OK: 2268 / Failed: 0 / User-skipped: 422 / Auto-skipped: 0

@pawlooss1 pawlooss1 marked this pull request as ready for review September 19, 2022 14:51
Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one comment, good to take the opportunity to do the remove_user hook right this time 😄

Comment on lines 371 to 376
Params = #{user => LUser, server => LServer},
Args = [LUser, LServer],
ParamsWithLegacyArgs = ejabberd_hooks:add_args(Params, Args),
HostType = mongoose_acc:host_type(Acc),
run_hook_for_host_type(remove_user, HostType, Acc, [LUser, LServer]).
run_hook_for_host_type(remove_user, HostType, Acc, ParamsWithLegacyArgs).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, this is a hook that I always wanted to touch and never could, so this is a good chance 😃
The issue is that here we pass user and server, not knowing if they have been normalised already. See how so many subscribers will do again and again jid:nameprep and jid:nodeprep, or jid:make with both, just so that we can be sure they were normalised.

I think that the legacy arguments should stay as they are, but, the new argument should simply be a jid, a-la Jid = jid:make_bare(User, Server), and that way subscribers can be sure the string has been normalised.

In the case of the handler for ejabberd_sm it might feel redundant, we'll need to pattern match on the jid #jid{luser = LUser, lserver = LServer} to extract them, but at this point we can be sure we could omit nameprepping them later on.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 20, 2022

small_tests_24 / small_tests / c5e70f8
Reports root / small


small_tests_25 / small_tests / c5e70f8
Reports root / small


ldap_mnesia_24 / ldap_mnesia / c5e70f8
Reports root/ big
OK: 1992 / Failed: 0 / User-skipped: 742 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / c5e70f8
Reports root/ big
OK: 3826 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / c5e70f8
Reports root/ big
OK: 3826 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / c5e70f8
Reports root/ big
OK: 1992 / Failed: 0 / User-skipped: 742 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / c5e70f8
Reports root/ big
OK: 3800 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / c5e70f8
Reports root/ big
OK: 4200 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / c5e70f8
Reports root/ big
OK: 2113 / Failed: 0 / User-skipped: 621 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / c5e70f8
Reports root/ big
OK: 3826 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / c5e70f8
Reports root/ big
OK: 2453 / Failed: 0 / User-skipped: 616 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / c5e70f8
Reports root/ big
OK: 2292 / Failed: 0 / User-skipped: 609 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / c5e70f8
Reports root/ big
OK: 4200 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / c5e70f8
Reports root/ big
OK: 4186 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / c5e70f8
Reports root/ big
OK: 4200 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0

@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 20, 2022

small_tests_24 / small_tests / 0ba7a50
Reports root / small


small_tests_25 / small_tests / 0ba7a50
Reports root / small


ldap_mnesia_24 / ldap_mnesia / 0ba7a50
Reports root/ big
OK: 1992 / Failed: 0 / User-skipped: 742 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 0ba7a50
Reports root/ big
OK: 3826 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 0ba7a50
Reports root/ big
OK: 3826 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 0ba7a50
Reports root/ big
OK: 1992 / Failed: 0 / User-skipped: 742 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 0ba7a50
Reports root/ big
OK: 3800 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 0ba7a50
Reports root/ big
OK: 4200 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 0ba7a50
Reports root/ big
OK: 3826 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 0ba7a50
Reports root/ big
OK: 2113 / Failed: 0 / User-skipped: 621 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 0ba7a50
Reports root/ big
OK: 2453 / Failed: 0 / User-skipped: 616 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 0ba7a50
Reports root/ big
OK: 4200 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 0ba7a50
Reports root/ big
OK: 4200 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / 0ba7a50
Reports root/ big
OK: 4185 / Failed: 1 / User-skipped: 111 / Auto-skipped: 0

service_domain_db_SUITE:db:db_reinserted_from_one_node_while_service_disabled_on_another
{error,
  {{badmatch,{ok,<<"dbgroup2">>}},
   [{service_domain_db_SUITE,
      db_reinserted_from_one_node_while_service_disabled_on_another,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,617}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log


riak_mnesia_24 / riak_mnesia / 0ba7a50
Reports root/ big
OK: 2292 / Failed: 0 / User-skipped: 609 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / 0ba7a50
Reports root/ big
OK: 4185 / Failed: 1 / User-skipped: 111 / Auto-skipped: 0

muc_SUITE:hibernation:hibernated_room_can_be_queried_for_archive
{error,{{assertion_failed,assert,is_groupchat_message,
              [<<"Restorable message">>],
              undefined,"undefined"},
    [{escalus_new_assert,assert_true,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
                {line,84}]},
     {muc_SUITE,wait_for_mam_result,3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4394}]},
     {muc_SUITE,'-hibernated_room_can_be_queried_for_archive/1-fun-0-',3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4130}]},
     {escalus_story,story,4,
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
             {line,72}]},
     {muc_SUITE,hibernated_room_can_be_queried_for_archive,1,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4126}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1291}]},
     {test_server,run_test_case_eval,9,
            [{file,"test_server.erl"},{line,1223}]}]}}

Report log


mysql_redis_25 / mysql_redis / 0ba7a50
Reports root/ big
OK: 4186 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0

Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent 👌🏽

@NelsonVides NelsonVides merged commit 2fcd129 into master Sep 20, 2022
@NelsonVides NelsonVides deleted the hooks/ejabberd_sm branch September 20, 2022 14:21
@chrzaszcz chrzaszcz added this to the 6.0.0 milestone Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants