1
0
mirror of https://github.com/algora-io/tv.git synced 2024-11-16 00:58:59 +02:00

add route /:channel_handle/latest

This commit is contained in:
zafer 2024-04-05 22:24:34 +03:00
parent 04cef55c1d
commit 3e23055042
2 changed files with 18 additions and 0 deletions

View 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

View File

@ -48,6 +48,7 @@ defmodule AlgoraWeb.Router do
scope "/", AlgoraWeb do
pipe_through [:browser, :embed]
get "/:channel_handle/latest", VideoPopoutController, :get
get "/:channel_handle/chat", ChatPopoutController, :get
get "/:channel_handle/embed", EmbedPopoutController, :get