-
Notifications
You must be signed in to change notification settings - Fork 429
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
GraphQL - Implement session api #3521
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/graphql #3521 +/- ##
===================================================
+ Coverage 81.23% 81.33% +0.10%
===================================================
Files 446 449 +3
Lines 32763 32854 +91
===================================================
+ Hits 26614 26721 +107
+ Misses 6149 6133 -16
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
e274c22
to
a16e25e
Compare
This comment has been minimized.
This comment has been minimized.
a16e25e
to
4a2d87b
Compare
This comment has been minimized.
This comment has been minimized.
4a2d87b
to
dc65904
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
49e72cd
to
97e7244
Compare
internal_mnesia_24 / internal_mnesia / 97e7244 small_tests_23 / small_tests / 97e7244 small_tests_24 / small_tests / 97e7244 dynamic_domains_mysql_redis_24 / mysql_redis / 97e7244 dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 97e7244 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 97e7244 ldap_mnesia_23 / ldap_mnesia / 97e7244 ldap_mnesia_24 / ldap_mnesia / 97e7244 mysql_redis_24 / mysql_redis / 97e7244 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 97e7244 mssql_mnesia_24 / odbc_mssql_mnesia / 97e7244 pgsql_mnesia_24 / pgsql_mnesia / 97e7244 riak_mnesia_24 / riak_mnesia / 97e7244 internal_mnesia_24 / internal_mnesia / 97e7244 internal_mnesia_24 / internal_mnesia / 97e7244 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me. I know it was not in the doc, but I think there should be a command allowing the user to set their own presence - just like the admin command. Otherwise the API is kind of incomplete.
init_per_group(_, Config) -> | ||
Config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? There are no other groups.
end_per_group(_, _Config) -> | ||
ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
?assertMatch([#{<<"user">> := ExpectedUser}], get_ok_value(Path, Result)). | ||
|
||
admin_list_sessions(Config) -> | ||
escalus:story(Config, [{alice, 1}, {alice_bis, 1}, {bob, 1}], fun(_Alice, AliceB, _Bob) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do these separate story functions for all test cases?
AwayPresence = escalus_stanza:presence_show(AwayStatus), | ||
DndStatus = <<"dnd">>, | ||
DndPresence = escalus_stanza:presence_show(DndStatus), | ||
% Count users with away status globally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
% Count users with away status globally | |
% List users with away status globally |
StatusUsers = get_ok_value(Path, Res), | ||
?assertEqual(2, length(StatusUsers)), | ||
?assert(users_match([AliceJID, AliceBJID], StatusUsers)), | ||
% Count users with away status for a domain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
} | ||
|
||
"Short info about user's status" | ||
type StatusUser{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type StatusUser{ | |
type UserStatus{ |
|
||
-spec null_to_empty(null | integer() | binary()) -> binary(). | ||
null_to_empty(null) -> <<>>; | ||
null_to_empty(Int) when is_integer(Int)-> integer_to_binary(Int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null_to_empty(Int) when is_integer(Int)-> integer_to_binary(Int); | |
null_to_empty(Int) when is_integer(Int) -> integer_to_binary(Int); |
src/mongoose_session_api.erl
Outdated
-type status_user_info() :: { User :: jid:user(), | ||
Server :: jid:server(), | ||
Res :: jid:resource(), | ||
Prio :: ejabberd_sm:priority(), | ||
Status :: status()}. | ||
|
||
-type session_info() :: {USR :: binary(), | ||
Conn :: binary(), | ||
IPS :: binary(), | ||
Port :: inet:port_number(), | ||
Prio :: ejabberd_sm:priority(), | ||
NodeS :: binary(), | ||
Uptime :: integer()}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation
src/mongoose_session_api.erl
Outdated
maybe_pres_priority(Priority, | ||
maybe_pres_show(Show, []))), | ||
Message = {xmlstreamelement, | ||
#xmlel{ name = <<"presence">>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#xmlel{ name = <<"presence">>, | |
#xmlel{name = <<"presence">>, |
src/mongoose_session_api.erl
Outdated
|| #session{sid = {_, Pid}, usr = {_, S, _}, priority = P} | ||
<- Sessions0 ], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| #session{sid = {_, Pid}, usr = {_, S, _}, priority = P} | |
<- Sessions0 ], | |
|| #session{sid = {_, Pid}, usr = {_, S, _}, priority = P} <- Sessions0 ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to comment, but I clicked 'approve' by mistake, apparently the code is just good 🙂
97e7244
to
d34f161
Compare
This comment was marked as outdated.
This comment was marked as outdated.
small_tests_24 / small_tests / 4412621 small_tests_23 / small_tests / 4412621 dynamic_domains_mysql_redis_24 / mysql_redis / 4412621 dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 4412621 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 4412621 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 4412621 ldap_mnesia_24 / ldap_mnesia / 4412621 ldap_mnesia_23 / ldap_mnesia / 4412621 internal_mnesia_24 / internal_mnesia / 4412621 pgsql_mnesia_24 / pgsql_mnesia / 4412621 mysql_redis_24 / mysql_redis / 4412621 pgsql_mnesia_23 / pgsql_mnesia / 4412621 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 4412621 mssql_mnesia_24 / odbc_mssql_mnesia / 4412621 riak_mnesia_24 / riak_mnesia / 4412621 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This PR addresses MIM-1581 and adds support for the session category.
All session command functions have been extracted to the
mongoose_session_api
module.