diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mediasync/router.ex | 23 | ||||
-rw-r--r-- | lib/mediasync/templates.ex | 13 |
2 files changed, 17 insertions, 19 deletions
diff --git a/lib/mediasync/router.ex b/lib/mediasync/router.ex index 2a80882..2e8b421 100644 --- a/lib/mediasync/router.ex +++ b/lib/mediasync/router.ex @@ -42,7 +42,7 @@ defmodule Mediasync.Router do enable_discord_activity? and Map.has_key?(conn.query_params, query_param_discord_activity_inner()) -> - send_resp(conn, 200, Mediasync.Templates.home(:discord_activity)) + send_resp(conn, 200, Mediasync.Templates.home(true)) true -> send_resp(conn, 200, Mediasync.Templates.home()) @@ -112,24 +112,19 @@ defmodule Mediasync.Router do case Registry.lookup(Mediasync.RoomRegistry, room_id) do [{pid, _value}] -> - video_info = Mediasync.Room.get_video_info(pid) - - {video_info, websocket_path, state_url, home_url} = - if Application.fetch_env!(:mediasync, :enable_discord_activity?) and - Map.has_key?(conn.query_params, query_param_discord_activity_inner()) do - {%{video_info | url: "/.proxy/room/#{room_id}/video"}, - "/.proxy/room/#{room_id}/websocket?#{query_param_discord_activity_inner()}", - "/.proxy/room/#{room_id}/state.json?#{query_param_discord_activity_inner()}", - "/.proxy/?#{query_param_discord_activity_inner()}"} - else - {video_info, "/room/#{room_id}/websocket", "/room/#{room_id}/state.json", nil} - end + in_discord_activity? = + Application.fetch_env!(:mediasync, :enable_discord_activity?) and + Map.has_key?(conn.query_params, query_param_discord_activity_inner()) conn |> put_html_content_type() |> send_resp( 200, - Mediasync.Templates.room(video_info, websocket_path, state_url, home_url) + Mediasync.Templates.room( + Mediasync.Room.get_video_info(pid), + room_id, + in_discord_activity? + ) ) [] -> diff --git a/lib/mediasync/templates.ex b/lib/mediasync/templates.ex index c6b15cc..b9ef937 100644 --- a/lib/mediasync/templates.ex +++ b/lib/mediasync/templates.ex @@ -2,16 +2,19 @@ defmodule Mediasync.Templates do require EEx def home() do - home(:normal) + home(false) end - EEx.function_from_file(:def, :home, "priv/home.html.eex", [:mode]) + def room(video_info, room_id) do + room(video_info, room_id, false) + end + + EEx.function_from_file(:def, :home, "priv/home.html.eex", [:in_discord_activity?]) EEx.function_from_file(:def, :room, "priv/room.html.eex", [ :video_info, - :websocket_path, - :state_url, - :home_url + :room_id, + :in_discord_activity? ]) EEx.function_from_file(:def, :discord_activity, "priv/discord_activity.html.eex") |