summaryrefslogtreecommitdiff
path: root/lib/matrix_app_service/application.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/matrix_app_service/application.ex')
-rw-r--r--lib/matrix_app_service/application.ex23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/matrix_app_service/application.ex b/lib/matrix_app_service/application.ex
index 38f65be..383c0f9 100644
--- a/lib/matrix_app_service/application.ex
+++ b/lib/matrix_app_service/application.ex
@@ -18,9 +18,10 @@ defmodule MatrixAppService.Application do
]
children =
- if Mix.env() == :test do
+ if start_endpoint?() do
[
- MatrixAppServiceWeb.TestEndpoint
+ # MatrixAppServiceWeb.Endpoint
+ {MatrixAppServiceWeb.Endpoint, endpoint_config()}
| children
]
else
@@ -36,10 +37,26 @@ defmodule MatrixAppService.Application do
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
- if Application.get_env(:matrix_app_service, :standalone, false) do
+ if start_endpoint?() do
MatrixAppServiceWeb.Endpoint.config_change(changed, removed)
end
:ok
end
+
+ def start_endpoint?() do
+ Application.get_env(:matrix_app_service, :internal_supervisor, false)
+ end
+
+ def endpoint_config() do
+ [
+ transaction_adapter: Application.fetch_env!(:matrix_app_service, :transaction_adapter),
+ room_adapter: Application.fetch_env!(:matrix_app_service, :room_adapter),
+ user_adapter: Application.fetch_env!(:matrix_app_service, :user_adapter),
+ homeserver_token: Application.fetch_env!(:matrix_app_service, :homeserver_token),
+ access_token: Application.fetch_env!(:matrix_app_service, :access_token),
+ base_url: Application.fetch_env!(:matrix_app_service, :base_url),
+ path: Application.get_env(:matrix_app_service, :path, "/")
+ ]
+ end
end