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

Allow JIDs from all MUC light domains in HTTP room API #1622

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

arkgil
Copy link
Contributor

@arkgil arkgil commented Jan 3, 2018

This PR allows passing room JID from all configured MUC light domains in HTTP room API routes. Previously the JID needed to be in a "primary" MUC light domain on host (started via mod_muc_light:start/2). If only username part of JID is given, still "primary" domain is assumed.

@fenek fenek force-pushed the http-room-api-allow-jids-from-var-domains branch from f771724 to 7b0267d Compare January 26, 2018 05:09

-spec validate_room_host(binary()) -> ok | error.
validate_room_host(RoomHost) ->
MucLightDomains = ejabberd_router:dirty_get_routes_to_module(mod_muc_light),
Copy link
Member

Choose a reason for hiding this comment

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

Feels a bit hackish. Instead of adding this API, can we reuse mongoose_subhosts:get_host/1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still, we're not sure if that subhost is a MUC light domain. IMO router is a more appropriate place to look for that information, because it is exactly the place where that information is registered (I mean the host <-> module mapping).

-spec validate_room_host(binary()) -> ok | error.
validate_room_host(RoomHost) ->
MucLightDomains = ejabberd_router:dirty_get_routes_to_module(mod_muc_light),
case lists:member(RoomHost, MucLightDomains) of
Copy link
Contributor

Choose a reason for hiding this comment

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

this would not work well in case of a lot of domains.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I need to come up with better solution.

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.

Can we have a test for this one?

arcusfelis and others added 2 commits April 30, 2018 12:21
Log message:
Lager fatally failed to install handler lager_console_backend into
lager_event, NOT retrying: {bad_console_config, info}
Fix broken lager_console_backend backend
@arkgil
Copy link
Contributor Author

arkgil commented May 7, 2018

@arcusfelis @fenek in hope to address concerns of both of you, I propose to replace dirty_get_routes_to_module with dirty_check_route_exists/2 which would take a domain and a module as a parameter, and return true if a route to that domain handled by such module exists.

@arcusfelis
Copy link
Contributor

@arkgil dirty_check_route_exists/2 makes sense.

@fenek
Copy link
Member

fenek commented May 7, 2018

@arkgil

OK, sounds good. :) Also I think that dirty_is_route_handler_module/2 would be more accurate. dirty_get_route_handler_module/1 would be fine as well. :)

@arkgil arkgil force-pushed the http-room-api-allow-jids-from-var-domains branch from 7b0267d to 1d40acd Compare May 8, 2018 11:07
@arkgil
Copy link
Contributor Author

arkgil commented May 8, 2018

@fenek @arcusfelis I've added negative test cases and one test to ensure that rooms can be actually created at different domain. However I noticed that if we'd like to fully support running multiple MUC light services on a single host, couple of changes would need to be made, e.g.:

  • drop the uniqueness constraint on room IDs and force uniqueness only in the scope of a single domain
  • allow to start multiple instances of the same module attached to a single XMPP host served by Mongoose

@Neustradamus

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants