mirror of
https://github.com/algora-io/tv.git
synced 2024-11-26 01:00:20 +02:00
add og_image_url to video
This commit is contained in:
parent
e9ce649ad9
commit
edf1c32e59
@ -411,6 +411,20 @@ defmodule Algora.Library do
|
||||
end
|
||||
end
|
||||
|
||||
def get_og_image_url(%Video{} = video) do
|
||||
video.og_image_url || get_thumbnail_url(video)
|
||||
end
|
||||
|
||||
def get_og_image_url(%User{} = user) do
|
||||
case get_latest_video(user) do
|
||||
nil ->
|
||||
get_thumbnail_url(user)
|
||||
|
||||
video ->
|
||||
get_og_image_url(video)
|
||||
end
|
||||
end
|
||||
|
||||
def reconcile_livestream(%Video{} = video, stream_key) do
|
||||
user = Accounts.get_user_by!(stream_key: stream_key)
|
||||
|
||||
|
@ -18,6 +18,7 @@ defmodule Algora.Library.Video do
|
||||
field :is_live, :boolean, default: false
|
||||
field :thumbnail_url, :string
|
||||
field :vertical_thumbnail_url, :string
|
||||
field :og_image_url, :string
|
||||
field :url, :string
|
||||
field :url_root, :string
|
||||
field :uuid, :string
|
||||
|
@ -6,7 +6,7 @@ defmodule AlgoraWeb.GithubController do
|
||||
def get_thumbnail(conn, %{"user_id" => user_id}) do
|
||||
case Accounts.get_user_by_provider_id(:github, user_id) do
|
||||
nil -> send_resp(conn, 404, "Not found")
|
||||
user -> redirect(conn, external: Library.get_thumbnail_url(user))
|
||||
user -> redirect(conn, external: Library.get_og_image_url(user))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -319,7 +319,7 @@ defmodule AlgoraWeb.ChannelLive do
|
||||
socket
|
||||
|> assign(:page_title, socket.assigns.channel.name || params["channel_handle"])
|
||||
|> assign(:page_description, socket.assigns.channel.tagline)
|
||||
|> assign(:page_image, Library.get_thumbnail_url(user))
|
||||
|> assign(:page_image, Library.get_og_image_url(user))
|
||||
end
|
||||
|
||||
defp show_stream_modal(socket) do
|
||||
|
@ -184,6 +184,6 @@ defmodule AlgoraWeb.ChatLive do
|
||||
socket
|
||||
|> assign(:page_title, socket.assigns.channel.name || params["channel_handle"])
|
||||
|> assign(:page_description, socket.assigns.video.title)
|
||||
|> assign(:page_image, Library.get_thumbnail_url(socket.assigns.video))
|
||||
|> assign(:page_image, Library.get_og_image_url(socket.assigns.video))
|
||||
end
|
||||
end
|
||||
|
@ -154,6 +154,6 @@ defmodule AlgoraWeb.EmbedLive do
|
||||
socket
|
||||
|> assign(:page_title, socket.assigns.channel.name || params["channel_handle"])
|
||||
|> assign(:page_description, socket.assigns.video.title)
|
||||
|> assign(:page_image, Library.get_thumbnail_url(socket.assigns.video))
|
||||
|> assign(:page_image, Library.get_og_image_url(socket.assigns.video))
|
||||
end
|
||||
end
|
||||
|
@ -634,7 +634,7 @@ defmodule AlgoraWeb.VideoLive do
|
||||
socket
|
||||
|> assign(:page_title, socket.assigns.channel.name || params["channel_handle"])
|
||||
|> assign(:page_description, socket.assigns.video.title)
|
||||
|> assign(:page_image, Library.get_thumbnail_url(socket.assigns.video))
|
||||
|> assign(:page_image, Library.get_og_image_url(socket.assigns.video))
|
||||
end
|
||||
|
||||
defp show_stream_modal(socket) do
|
||||
|
@ -0,0 +1,9 @@
|
||||
defmodule Algora.Repo.Local.Migrations.AddOgImageUrlToVideo do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table("videos") do
|
||||
add :og_image_url, :string
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user