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

GraphQL - Implement MUC Light rooms API for admin #3538

Merged
merged 10 commits into from
Mar 2, 2022

Conversation

Premwoik
Copy link
Contributor

@Premwoik Premwoik commented Feb 9, 2022

This PR addresses MIM-1600. It adds MUC Light admin API for GraphQL. The user part should be implemented in the next PR.

The new mod_muc_light_api extracted from mod_muc_light_commands catches all errors and returns them as a {ErrCode, Message} tuple. Previously these functions could fail in some cases (e.g. passing a non-existing domain).

The old REST API now expects MUCLightServer in each command instead of Server. Previously it depended on the command, and now it is unified.

Before, some commands use room name instead of room id. The room name is not unique and user can have more than one room with the same name. It is unified now and room id is used everywhere.

@Premwoik Premwoik changed the base branch from master to feature/graphql February 9, 2022 19:01
@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Feb 9, 2022

Codecov Report

Merging #3538 (198cc90) into feature/graphql (a957367) will increase coverage by 0.04%.
The diff coverage is 92.57%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/graphql    #3538      +/-   ##
===================================================
+ Coverage            81.32%   81.37%   +0.04%     
===================================================
  Files                  449      454       +5     
  Lines                32854    32955     +101     
===================================================
+ Hits                 26719    26817      +98     
- Misses                6135     6138       +3     
Impacted Files Coverage Δ
src/graphql/mongoose_graphql.erl 91.11% <ø> (ø)
src/graphql/mongoose_graphql_enum.erl 36.36% <33.33%> (-6.50%) ⬇️
src/muc_light/mod_muc_light_commands.erl 85.29% <83.33%> (-6.48%) ⬇️
.../mongoose_client_api/mongoose_client_api_rooms.erl 90.27% <85.71%> (+0.13%) ⬆️
src/muc_light/mod_muc_light_api.erl 95.04% <95.04%> (ø)
.../graphql/admin/mongoose_graphql_admin_mutation.erl 100.00% <100.00%> (ø)
src/graphql/admin/mongoose_graphql_admin_query.erl 100.00% <100.00%> (ø)
...dmin/mongoose_graphql_muc_light_admin_mutation.erl 100.00% <100.00%> (ø)
...l/admin/mongoose_graphql_muc_light_admin_query.erl 100.00% <100.00%> (ø)
...phql/admin/mongoose_graphql_stanza_admin_query.erl 100.00% <100.00%> (ø)
... and 16 more

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 a957367...198cc90. Read the comment docs.

@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.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@Premwoik Premwoik changed the title GraphQL - Implement MUC Light rooms API GraphQL - Implement MUC Light rooms API for admin Feb 17, 2022
@mongoose-im
Copy link
Collaborator

mongoose-im commented Feb 17, 2022

small_tests_24 / small_tests / 04a5863
Reports root / small


small_tests_23 / small_tests / 04a5863
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 04a5863
Reports root/ big
OK: 2777 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 04a5863
Reports root/ big
OK: 2777 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 04a5863
Reports root/ big
OK: 2760 / Failed: 0 / User-skipped: 255 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 04a5863
Reports root/ big
OK: 2777 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 04a5863
Reports root/ big
OK: 1553 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 04a5863
Reports root/ big
OK: 1599 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 04a5863
Reports root/ big
OK: 3164 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 04a5863
Reports root/ big
OK: 1553 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 04a5863
Reports root/ big
OK: 3164 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 04a5863
Reports root/ big
OK: 3159 / Failed: 0 / User-skipped: 252 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 04a5863
Reports root/ big
OK: 3164 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 04a5863
Reports root/ big
OK: 1905 / Failed: 0 / User-skipped: 378 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 04a5863
Reports root/ big
OK: 1752 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0

@Premwoik Premwoik marked this pull request as ready for review February 17, 2022 11:12
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.

Looks good to me in general. I think that (as we discussed) it might make more sense to use JID to identify the room in the whole API.

big_tests/tests/graphql_muc_light_SUITE.erl Outdated Show resolved Hide resolved
big_tests/tests/graphql_muc_light_SUITE.erl Outdated Show resolved Hide resolved
big_tests/tests/graphql_muc_light_SUITE.erl Outdated Show resolved Hide resolved
big_tests/tests/graphql_muc_light_SUITE.erl Outdated Show resolved Hide resolved
big_tests/tests/graphql_muc_light_SUITE.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

Also use MUCLightDomain in commands instead of Domain. Apply review comments.
Revert `XMPPMUCHOST` for admin REST API instead of `XMPPHOST`. Apply review comments.
@mongoose-im
Copy link
Collaborator

mongoose-im commented Feb 23, 2022

small_tests_24 / small_tests / e14f8f6
Reports root / small


small_tests_23 / small_tests / e14f8f6
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / e14f8f6
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / e14f8f6
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / e14f8f6
Reports root/ big
OK: 2761 / Failed: 0 / User-skipped: 255 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / e14f8f6
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / e14f8f6
Reports root/ big
OK: 1554 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / e14f8f6
Reports root/ big
OK: 1554 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / e14f8f6
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / e14f8f6
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / e14f8f6
Reports root/ big
OK: 1906 / Failed: 0 / User-skipped: 378 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / e14f8f6
Reports root/ big
OK: 1600 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / e14f8f6
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / e14f8f6
Reports root/ big
OK: 3160 / Failed: 0 / User-skipped: 252 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / e14f8f6
Reports root/ big
OK: 1753 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0

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.

Looks good in general, I added a few minor comments.

big_tests/tests/rest_client_SUITE.erl Outdated Show resolved Hide resolved
priv/graphql/schemas/admin/muc_light.gql Outdated Show resolved Hide resolved

-spec create_room(map()) -> {ok, map()} | {error, resolver_error()}.
create_room(#{<<"id">> := null} = Args) ->
create_room(Args#{<<"id">> => <<>>});
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to accept empty binary in the GraphQL query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An empty string, in this case, means that id is not present and should be generated. It was done this way in the old commands module. I can return an error when id is empty to eliminate the situation that someone passes an empty string by the accident. Should I do it this way?

Copy link
Member

@chrzaszcz chrzaszcz Mar 2, 2022

Choose a reason for hiding this comment

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

That was the point - the logic for "" is a side-effect of the way it is coded. I think it can stay as it is for now. I think that the policy for empty binaries should be similar as e.g. for empty binary for user name, jid etc.

src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
@mongoose-im
Copy link
Collaborator

mongoose-im commented Mar 1, 2022

small_tests_24 / small_tests / 28f484f
Reports root / small


small_tests_23 / small_tests / 28f484f
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 28f484f
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 28f484f
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 28f484f
Reports root/ big
OK: 2761 / Failed: 0 / User-skipped: 255 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 28f484f
Reports root/ big
OK: 1554 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 28f484f
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 28f484f
Reports root/ big
OK: 1554 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 28f484f
Reports root/ big
OK: 1600 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 28f484f
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 28f484f
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 28f484f
Reports root/ big
OK: 1906 / Failed: 0 / User-skipped: 378 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 28f484f
Reports root/ big
OK: 3160 / Failed: 0 / User-skipped: 252 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 28f484f
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 28f484f
Reports root/ big
OK: 1753 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0

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.

Looks good to me 👍

src/muc_light/mod_muc_light_api.erl Outdated Show resolved Hide resolved
@mongoose-im
Copy link
Collaborator

mongoose-im commented Mar 2, 2022

small_tests_24 / small_tests / 198cc90
Reports root / small


small_tests_23 / small_tests / 198cc90
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 198cc90
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 198cc90
Reports root/ big
OK: 2761 / Failed: 0 / User-skipped: 255 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 198cc90
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 198cc90
Reports root/ big
OK: 2778 / Failed: 0 / User-skipped: 238 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 198cc90
Reports root/ big
OK: 1554 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 198cc90
Reports root/ big
OK: 1554 / Failed: 0 / User-skipped: 423 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 198cc90
Reports root/ big
OK: 1600 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 198cc90
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 198cc90
Reports root/ big
OK: 1906 / Failed: 0 / User-skipped: 378 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 198cc90
Reports root/ big
OK: 3160 / Failed: 0 / User-skipped: 252 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 198cc90
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 198cc90
Reports root/ big
OK: 3165 / Failed: 0 / User-skipped: 247 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 198cc90
Reports root/ big
OK: 1753 / Failed: 0 / User-skipped: 377 / Auto-skipped: 0

@chrzaszcz chrzaszcz merged commit 5dd5d59 into feature/graphql Mar 2, 2022
@chrzaszcz chrzaszcz deleted the graphql/muc-light-api branch March 2, 2022 16:44
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants