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

Remove unnecessary hooks #3990

Merged
merged 2 commits into from
Apr 3, 2023
Merged

Remove unnecessary hooks #3990

merged 2 commits into from
Apr 3, 2023

Conversation

jacekwegr
Copy link
Contributor

@jacekwegr jacekwegr commented Mar 20, 2023

This PR removes some of the hooks that had no handlers registered to them in order to lower the code complexity.

List of the hooks that have no handlers, with an explanation why they were or weren't removed:

  • user_ping_timeout, c2s_update_presence - these hooks were already removed
  • adhoc_sm_commands - if we already have local_commands, it makes sense to also have sm_commands
  • vcard_set - might be used to notify about the need to download the vcard again
  • check_bl_c2s - it is useful and doesn’t add too much logic
  • forbidden_session_hook - it seems useful and doesn’t complicate the code much
  • session_opening_allowed_for_user - can be removed, but I think it’s better to leave it as is
  • set_presence_hook - doesn’t complicate logic very much and can be useful in the future
  • roster_groups - might be useful for some implementations that don’t allow some roster groups to subscribe to pubsub
  • find_s2s_bridge - always returned undefined and was causing unnecessary branching
  • s2s_allow_host - might be useful in the future and doesn’t complicate code very much
  • s2s_connect_hook - removed, always returned ok
  • s2s_send_packet, s2s_receive_packet - left because it might be useful to know whether a message is routed
  • invitation_sent - left because there is a TODO in mod_inbbox_muc.erl
  • join_room, reave_room, room_packet - not used anywhere, but may be needed in some implementations
  • pubsub_create_node, pubsub_delete_node, pubsub_publish_item - not very useful as this information is already broadcast. Furthermore, removing these hooks allows for some code to be simplified.
  • mam_retraction, mam_muc_retraction - can be useful for implementations that use message retractions

@jacekwegr jacekwegr marked this pull request as draft March 20, 2023 16:49
@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Mar 20, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (afb9ecf) 82.06% compared to head (f2ce066) 82.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3990      +/-   ##
==========================================
+ Coverage   82.06%   82.10%   +0.03%     
==========================================
  Files         536      536              
  Lines       33902    33859      -43     
==========================================
- Hits        27822    27799      -23     
+ Misses       6080     6060      -20     
Impacted Files Coverage Δ
src/hooks/mongoose_hooks.erl 95.68% <ø> (-0.17%) ⬇️
src/inbox/mod_inbox_muc.erl 91.42% <ø> (ø)
src/mod_muc_room.erl 78.45% <ø> (ø)
src/pubsub/mod_pubsub.erl 73.62% <ø> (+0.14%) ⬆️
src/ejabberd_s2s_out.erl 64.43% <100.00%> (+2.27%) ⬆️

... and 7 files with indirect coverage changes

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 in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@jacekwegr jacekwegr marked this pull request as ready for review March 22, 2023 10:40
@@ -419,19 +412,6 @@ user_ping_response(HostType, Acc, JID, Response, TDelta) ->
Params = #{jid => JID, response => Response, time_delta => TDelta},
run_hook_for_host_type(user_ping_response, HostType, Acc, Params).

%%% @doc The `vcard_set' hook is called to inform that the vcard
Copy link
Contributor

Choose a reason for hiding this comment

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

it is pretty useful when we need to notify about need to download vcard again (if avatar is stored there).

Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

looks ok

@mongoose-im

This comment was marked as outdated.

text => <<"Found a bridge, relay_to_bridge next.">>,
type => Type,
myname => StateData#state.myname, server => StateData#state.server}),
NewStateData = StateData#state{bridge={Mod, Fun}},
Copy link
Contributor

@arcusfelis arcusfelis Mar 28, 2023

Choose a reason for hiding this comment

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

Once you remove this, I think #state.bridge is unused (also, relay_to_bridge state).
So, we need to check what are the bridges. It could be even non-tested feature.

You can probably remove bridge attribute and relay_to_bridge statename (i.e. exported function callback). And check if tests are still passing.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Apr 3, 2023

small_tests_25_arm64 / small_tests / f2ce066
Reports root / small


small_tests_24 / small_tests / f2ce066
Reports root / small


small_tests_25 / small_tests / f2ce066
Reports root / small


ldap_mnesia_24 / ldap_mnesia / f2ce066
Reports root/ big
OK: 2219 / Failed: 0 / User-skipped: 825 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / f2ce066
Reports root/ big
OK: 4178 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / f2ce066
Reports root/ big
OK: 2219 / Failed: 0 / User-skipped: 825 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / f2ce066
Reports root/ big
OK: 4151 / Failed: 1 / User-skipped: 114 / Auto-skipped: 0

graphql_session_SUITE:admin_session:admin_session_cli:admin_kick_user_session
{error,
  {function_clause,
    [{graphql_helper,get_error,
       [1,
        {{<<"200">>,<<"OK">>},
         #{<<"data">> =>
           #{<<"session">> =>
               #{<<"kickUserSession">> =>
                 #{<<"code">> => null,
                   <<"jid">> =>
                     <<"[email protected]/res1">>,
                   <<"kicked">> => true,
                   <<"message">> => <<"Session kicked">>}}}}}],
       []},
     {graphql_helper,get_err_msg,2,
       [{file,
          "/home/circleci/project/big_tests/tests/graphql_helper.erl"},
        {line,227}]},
     {graphql_session_SUITE,admin_kick_user_session_story,3,
       [{file,
          "/home/circleci/project/big_tests/tests/graphql_session_SUITE.erl"},
        {line,441}]},
     {escalus_story,story,4,
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
        {line,72}]},
     {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


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / f2ce066
Reports root/ big
OK: 4178 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / f2ce066
Reports root/ big
OK: 4175 / Failed: 0 / User-skipped: 91 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / f2ce066
Reports root/ big
OK: 2361 / Failed: 0 / User-skipped: 683 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / f2ce066
Reports root/ big
OK: 2721 / Failed: 0 / User-skipped: 662 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / f2ce066
Reports root/ big
OK: 4551 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / f2ce066
Reports root/ big
OK: 4551 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / f2ce066
Reports root/ big
OK: 4548 / Failed: 0 / User-skipped: 100 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / f2ce066
Reports root/ big
OK: 4537 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / f2ce066
Reports root/ big
OK: 4152 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0

Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

good

@arcusfelis arcusfelis merged commit 3698656 into master Apr 3, 2023
@arcusfelis arcusfelis deleted the remove-unnecessary-hooks branch April 3, 2023 11:57
@jacekwegr jacekwegr added this to the 6.1.0 milestone Apr 26, 2023
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.

3 participants