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

c2s/presence #3746

Merged
merged 3 commits into from
Sep 20, 2022
Merged

c2s/presence #3746

merged 3 commits into from
Sep 20, 2022

Conversation

NelsonVides
Copy link
Collaborator

@NelsonVides NelsonVides commented Sep 2, 2022

This module implements xmpp presences. With presences, now default escalus can successfully connect, and that unblocks a myriad of test suites that can now pass.

@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Base: 13.58% // Head: 57.73% // Increases project coverage by +44.15% 🎉

Coverage data is based on head (4152aa9) compared to base (3d7a35a).
Patch coverage: 86.75% of modified lines in pull request are covered.

Additional details and impacted files
@@                    Coverage Diff                    @@
##           feature/mongoose_c2s    #3746       +/-   ##
=========================================================
+ Coverage                 13.58%   57.73%   +44.15%     
=========================================================
  Files                       535      536        +1     
  Lines                     34535    34809      +274     
=========================================================
+ Hits                       4690    20096    +15406     
+ Misses                    29845    14713    -15132     
Impacted Files Coverage Δ
src/c2s/mongoose_c2s_stanzas.erl 78.94% <ø> (+13.09%) ⬆️
src/jlib.erl 75.14% <80.00%> (+60.26%) ⬆️
src/mod_presence.erl 86.73% <86.73%> (ø)
src/c2s/mongoose_c2s.erl 61.17% <100.00%> (+14.43%) ⬆️
src/auth/ejabberd_auth_anonymous.erl 14.06% <0.00%> (+1.56%) ⬆️
src/pubsub/pubsub_form_utils.erl 1.88% <0.00%> (+1.88%) ⬆️
src/logger/mongoose_json_formatter.erl 76.00% <0.00%> (+2.00%) ⬆️
src/privacy/mod_privacy.erl 3.34% <0.00%> (+2.51%) ⬆️
src/c2s/mongoose_c2s_listener.erl 84.61% <0.00%> (+2.56%) ⬆️
src/wpool/mongoose_wpool_mgr.erl 46.47% <0.00%> (+2.81%) ⬆️
... and 388 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

This comment was marked as outdated.

@NelsonVides NelsonVides changed the title mod_presence c2s/presence Sep 2, 2022
@NelsonVides NelsonVides force-pushed the c2s/presences branch 2 times, most recently from a703a6c to bdc1f33 Compare September 3, 2022 13:15
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@NelsonVides NelsonVides force-pushed the c2s/presences branch 2 times, most recently from caaf56d to c6105e8 Compare September 7, 2022 15:50
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

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

It looks good to me 👍 My biggest concern is about the name Handler - it looks like a function or a callback, but it's just presence-related data with a type called presences(), so I think it could be just called Presences in the code as well.

big_tests/dynamic_domains.spec Outdated Show resolved Hide resolved
big_tests/dynamic_domains.spec Outdated Show resolved Hide resolved
src/config/mongoose_config_spec.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Outdated Show resolved Hide resolved
src/mod_presence.erl Show resolved Hide resolved
@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 19, 2022

small_tests_24 / small_tests / 1edaa0f
Reports root / small


ldap_mnesia_24 / ldap_mnesia / 1edaa0f
Reports root/ big
OK: 789 / Failed: 0 / User-skipped: 425 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 1edaa0f
Reports root/ big
OK: 789 / Failed: 0 / User-skipped: 425 / Auto-skipped: 0


small_tests_25 / small_tests / 1edaa0f
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 1edaa0f
Reports root/ big
OK: 2528 / Failed: 0 / User-skipped: 52 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 1edaa0f
Reports root/ big
OK: 2596 / Failed: 0 / User-skipped: 61 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 1edaa0f
Reports root/ big
OK: 849 / Failed: 0 / User-skipped: 365 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 1edaa0f
Reports root/ big
OK: 2528 / Failed: 0 / User-skipped: 52 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 1edaa0f
Reports root/ big
OK: 1185 / Failed: 0 / User-skipped: 364 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 1edaa0f
Reports root/ big
OK: 2511 / Failed: 0 / User-skipped: 69 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 1edaa0f
Reports root/ big
OK: 2528 / Failed: 0 / User-skipped: 52 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 1edaa0f
Reports root/ big
OK: 2596 / Failed: 0 / User-skipped: 61 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 1edaa0f
Reports root/ big
OK: 1032 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 1edaa0f
Reports root/ big
OK: 2596 / Failed: 0 / User-skipped: 61 / 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.

added comments, looks good

%% We have _subscription to_ these users' presence status;
%% i.e. they send us presence updates.
%% This comes from the roster.
pres_t = gb_sets:new() :: jid_set(),
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need pres_ prefix here.
So, maybe using subscribed_by and subscribed_to are better name.
available_to, invisible_to.
is_invisbile field.
last_stanza, last_timestamp.

Reasoning for longer names: we use longer names in the variables (i.e. ImAvailableTo), trying to describe what is going on. Instead of just putting this meaning into the field name.

Copy link
Member

Choose a reason for hiding this comment

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

I also had a discussion with @NelsonVides and he suggested minimizing the refactoring in this PR, so maybe it's acceptable as it is now?

#xmlel{attrs = Attrs} = Packet,
Attrs1 = lists:keystore(<<"type">>, 1, Attrs, {<<"type">>, <<"unavailable">>}),
NewElement = Packet#xmlel{attrs = Attrs1},
Acc1 = mongoose_acc:update_stanza(
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for Acc1 variable here and up. You can use typespecs though.

-spec presence_update(
mongoose_acc:t(), jid:jid(), jid:jid(), exml:element(), mongoose_c2s:c2s_data(), undefined | binary()) ->
mongoose_acc:t().
presence_update(Acc, FromJid, ToJid, Packet, StateData, undefined) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should use case here :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why? xD

Copy link
Contributor

Choose a reason for hiding this comment

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

less duplication of code for me. There is one argument to match and other arguments are repeated.
Though it is just my preference.

_ -> 0
end.

-spec get_old_priority(presences()) -> priority().
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the name presences here, because it is anything but not [#xmlel{name = <<"presence">>}] (i.e. presences to me).

Maybe pstate could be better.

Copy link
Member

Choose a reason for hiding this comment

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

It is correct that the name presences might suggest a list, but the type is clearly defined at the top, so I have no doubt what it means when reading the code. Anyway, presence_state might be better, but IMO it's ok as it is now.

Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

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

It looks good to me.

src/mod_presence.erl Show resolved Hide resolved
@mongoose-im
Copy link
Collaborator

mongoose-im commented Sep 20, 2022

ldap_mnesia_24 / ldap_mnesia / 4152aa9
Reports root/ big
OK: 789 / Failed: 0 / User-skipped: 425 / Auto-skipped: 0


small_tests_24 / small_tests / 4152aa9
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 4152aa9
Reports root/ big
OK: 789 / Failed: 0 / User-skipped: 425 / Auto-skipped: 0


small_tests_25 / small_tests / 4152aa9
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 4152aa9
Reports root/ big
OK: 2528 / Failed: 0 / User-skipped: 52 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 4152aa9
Reports root/ big
OK: 2596 / Failed: 0 / User-skipped: 61 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 4152aa9
Reports root/ big
OK: 849 / Failed: 0 / User-skipped: 365 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 4152aa9
Reports root/ big
OK: 2528 / Failed: 0 / User-skipped: 52 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 4152aa9
Reports root/ big
OK: 2511 / Failed: 0 / User-skipped: 69 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 4152aa9
Reports root/ big
OK: 2596 / Failed: 0 / User-skipped: 61 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 4152aa9
Reports root/ big
OK: 1185 / Failed: 0 / User-skipped: 364 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 4152aa9
Reports root/ big
OK: 1032 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 4152aa9
Reports root/ big
OK: 2596 / Failed: 0 / User-skipped: 61 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 4152aa9
Reports root/ big
OK: 2527 / Failed: 1 / User-skipped: 52 / Auto-skipped: 0

smart_markers_SUITE:regular:one2one:marker_for_thread_can_be_fetched
{error,
  {{fetch_marker,ok,
     [{times,50,
        {error,
          {badmatch,[]},
          [{smart_markers_SUITE,'-verify_marker_fetch/4-fun-6-',3,
             [{file,
              "/home/circleci/project/big_tests/tests/smart_markers_SUITE.erl"},
            {line,405}]},
           {mongoose_helper,do_wait_until,2,
             [{file,
              "/home/circleci/project/big_tests/tests/mongoose_helper.erl"},
            {line,374}]},
           {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}]}]}}]},
   [{mongoose_helper,do_wait_until,2,
      [{file,"/home/circleci/project/big_tests/tests/mongoose_helper.erl"},
       {line,371}]},
    {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

Base automatically changed from c2s_prototype to feature/mongoose_c2s September 20, 2022 13:10
@arcusfelis arcusfelis merged commit 6a2100c into feature/mongoose_c2s Sep 20, 2022
@arcusfelis arcusfelis deleted the c2s/presences branch September 20, 2022 13:51
@jacekwegr jacekwegr added this to the 6.1.0 milestone Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants