mirror of
https://github.com/algora-io/tv.git
synced 2024-11-26 01:00:20 +02:00
add route /:channel_handle/latest
This commit is contained in:
parent
04cef55c1d
commit
3e23055042
17
lib/algora_web/controllers/video_popout_controller.ex
Normal file
17
lib/algora_web/controllers/video_popout_controller.ex
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
defmodule AlgoraWeb.VideoPopoutController do
|
||||||
|
use AlgoraWeb, :controller
|
||||||
|
|
||||||
|
alias Algora.{Accounts, Library}
|
||||||
|
|
||||||
|
def get(conn, %{"channel_handle" => channel_handle}) do
|
||||||
|
user = Accounts.get_user_by!(handle: channel_handle)
|
||||||
|
|
||||||
|
case Library.get_latest_video(user) do
|
||||||
|
nil ->
|
||||||
|
redirect(conn, to: ~p"/#{user.handle}")
|
||||||
|
|
||||||
|
video ->
|
||||||
|
redirect(conn, to: ~p"/#{user.handle}/#{video.id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -48,6 +48,7 @@ defmodule AlgoraWeb.Router do
|
|||||||
scope "/", AlgoraWeb do
|
scope "/", AlgoraWeb do
|
||||||
pipe_through [:browser, :embed]
|
pipe_through [:browser, :embed]
|
||||||
|
|
||||||
|
get "/:channel_handle/latest", VideoPopoutController, :get
|
||||||
get "/:channel_handle/chat", ChatPopoutController, :get
|
get "/:channel_handle/chat", ChatPopoutController, :get
|
||||||
get "/:channel_handle/embed", EmbedPopoutController, :get
|
get "/:channel_handle/embed", EmbedPopoutController, :get
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user