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

Install a hook to filter messages being buffered #3654

Merged
merged 1 commit into from
May 25, 2022

Conversation

NelsonVides
Copy link
Collaborator

This can be used to insert handlers that would filter out stanzas with a
no-copy hint, or any other desired condition. The handler will have
access to the full buffer and can return an entirely new one,
preferably, by only filtering whichever stanza is to be undesired.

@mongoose-im
Copy link
Collaborator

mongoose-im commented May 23, 2022

small_tests_24 / small_tests / a77cd96
Reports root / small


small_tests_23 / small_tests / a77cd96
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / a77cd96
Reports root/ big
OK: 2862 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / a77cd96
Reports root/ big
OK: 2862 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / a77cd96
Reports root/ big
OK: 2845 / Failed: 0 / User-skipped: 150 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / a77cd96
Reports root/ big
OK: 1507 / Failed: 0 / User-skipped: 402 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / a77cd96
Reports root/ big
OK: 1507 / Failed: 0 / User-skipped: 402 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / a77cd96
Reports root/ big
OK: 2862 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / a77cd96
Reports root/ big
OK: 3236 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / a77cd96
Reports root/ big
OK: 1548 / Failed: 0 / User-skipped: 361 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / a77cd96
Reports root/ big
OK: 1855 / Failed: 0 / User-skipped: 369 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / a77cd96
Reports root/ big
OK: 3236 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / a77cd96
Reports root/ big
OK: 3231 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / a77cd96
Reports root/ big
OK: 3247 / Failed: 1 / User-skipped: 142 / Auto-skipped: 0

pep_SUITE:pep_tests:unsubscribe_after_presence_unsubscription
{error,
  {{badmatch,
     [{xmlel,<<"message">>,
        [{<<"from">>,
        <<"alice_unsubscribe_after_presence_unsubscription_1912@localhost">>},
         {<<"to">>,
        <<"bob_unsubscribe_after_presence_unsubscription_1912@localhost/res1">>},
         {<<"type">>,<<"headline">>}],
        [{xmlel,<<"event">>,
           [{<<"xmlns">>,
           <<"http://jabber.org/protocol/pubsub#event">>}],
           [{xmlel,<<"items">>,
            [{<<"node">>,<<"LNqNXCx+EBWgDE21fZ0gPQ==">>}],
            [{xmlel,<<"item">>,
               [{<<"id">>,<<"salmon">>}],
               [{xmlel,<<"entry">>,
                  [{<<"xmlns">>,
                  <<"http://www.w3.org/2005/Atom">>}],
                  []}]}]}]},
         {xmlel,<<"headers">>,
           [{<<"xmlns">>,<<"http://jabber.org/protocol/shim">>}],
           []}]}]},
   [{pep_SUITE,'-unsubscribe_after_presence_unsubscription/1-fun-0-',2,
      [{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
       {line,384}]},
    {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,1783}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1292}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1224}]}]}}

Report log


riak_mnesia_24 / riak_mnesia / a77cd96
Reports root/ big
OK: 1698 / Failed: 0 / User-skipped: 368 / Auto-skipped: 0

@codecov
Copy link

codecov bot commented May 23, 2022

Codecov Report

Merging #3654 (632e4f8) into master (66eaf0a) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3654      +/-   ##
==========================================
- Coverage   81.09%   81.07%   -0.02%     
==========================================
  Files         433      433              
  Lines       31938    31941       +3     
==========================================
- Hits        25900    25897       -3     
- Misses       6038     6044       +6     
Impacted Files Coverage Δ
src/ejabberd_c2s.erl 88.73% <100.00%> (-0.21%) ⬇️
src/mongoose_hooks.erl 95.45% <100.00%> (+0.02%) ⬆️
src/pubsub/node_pep.erl 77.77% <0.00%> (-3.71%) ⬇️
src/logger/mongoose_log_filter.erl 78.08% <0.00%> (-1.37%) ⬇️
src/pubsub/mod_pubsub.erl 73.42% <0.00%> (-0.07%) ⬇️
src/mod_muc_log.erl 63.21% <0.00%> (ø)
src/mod_roster.erl 78.70% <0.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66eaf0a...632e4f8. Read the comment docs.

re_route_packets(Buffer, StateData) ->
[reroute(Acc, StateData) || Acc <- lists:reverse(Buffer)],
re_route_packets(Buffer, #state{jid = Jid, host_type = HostType} = StateData) ->
FilteredBuffer = mongoose_hooks:filter_unacknowledged_messages(HostType, Jid, Buffer),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe a good idea to pass already reversed input into filter_unacknowledged_messages

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good one

This can be used to insert handlers that would filter out stanzas with a
`no-copy` hint, or any other desired condition. The handler will have
access to the full buffer and can return an entirely new one,
preferably, by only filtering whichever stanza is to be undesired.
@mongoose-im
Copy link
Collaborator

mongoose-im commented May 25, 2022

small_tests_24 / small_tests / 632e4f8
Reports root / small


small_tests_23 / small_tests / 632e4f8
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 632e4f8
Reports root/ big
OK: 2862 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 632e4f8
Reports root/ big
OK: 2845 / Failed: 0 / User-skipped: 150 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 632e4f8
Reports root/ big
OK: 2862 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 632e4f8
Reports root/ big
OK: 1507 / Failed: 0 / User-skipped: 402 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 632e4f8
Reports root/ big
OK: 2874 / Failed: 1 / User-skipped: 133 / 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,4383}]},
     {muc_SUITE,'-hibernated_room_can_be_queried_for_archive/1-fun-0-',3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4124}]},
     {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,4120}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1292}]},
     {test_server,run_test_case_eval,9,
            [{file,"test_server.erl"},{line,1224}]}]}}

Report log


ldap_mnesia_24 / ldap_mnesia / 632e4f8
Reports root/ big
OK: 1507 / Failed: 0 / User-skipped: 402 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 632e4f8
Reports root/ big
OK: 1548 / Failed: 0 / User-skipped: 361 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 632e4f8
Reports root/ big
OK: 1855 / Failed: 0 / User-skipped: 369 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 632e4f8
Reports root/ big
OK: 3236 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 632e4f8
Reports root/ big
OK: 3231 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 632e4f8
Reports root/ big
OK: 3235 / Failed: 1 / User-skipped: 142 / Auto-skipped: 0

service_domain_db_SUITE:db:db_keeps_syncing_after_cluster_join
{error,{test_case_failed,{[<<"example1.com">>,<<"example2.com">>,
               <<"example3.com">>],
              [<<"example1.com">>,<<"example2.com">>,
               <<"example3.com">>,<<"example4.com">>]}}}

Report log


mssql_mnesia_24 / odbc_mssql_mnesia / 632e4f8
Reports root/ big
OK: 3236 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 632e4f8
Reports root/ big
OK: 1698 / Failed: 0 / User-skipped: 368 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 632e4f8
Reports root/ big
OK: 3236 / Failed: 0 / User-skipped: 142 / 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.

ok

@arcusfelis arcusfelis merged commit 1320ffd into master May 25, 2022
@arcusfelis arcusfelis deleted the filter_bounce_buffers branch May 25, 2022 15:24
@Premwoik Premwoik added this to the 5.1.0 milestone Jun 6, 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.

None yet

4 participants