From 910d40a643dfa72a00174451990e9e814451955c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wid-Ga=C3=ABl=20Destin?= Date: Mon, 15 Mar 2021 18:52:56 +0100 Subject: [PATCH] Added unlisted videos limitations --- apps/cf/lib/videos/videos.ex | 5 ++++- apps/cf/priv/limitations.yaml | 1 + apps/db/lib/db_type/entity.ex | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/cf/lib/videos/videos.ex b/apps/cf/lib/videos/videos.ex index f5483966..828f2758 100644 --- a/apps/cf/lib/videos/videos.ex +++ b/apps/cf/lib/videos/videos.ex @@ -80,7 +80,10 @@ defmodule CF.Videos do Can also throw if bad permissions. """ def create!(user, video_url, params \\ []) do - UserPermissions.check!(user, :add, :video) + case Keyword.get(params, :unlisted, false) do + false -> UserPermissions.check!(user, :add, :video) + true -> UserPermissions.check!(user, :add, :unlisted_video) + end with metadata_fetcher when not is_nil(metadata_fetcher) <- get_metadata_fetcher(video_url), {:ok, metadata} <- metadata_fetcher.(video_url) do diff --git a/apps/cf/priv/limitations.yaml b/apps/cf/priv/limitations.yaml index f104f761..44306846 100644 --- a/apps/cf/priv/limitations.yaml +++ b/apps/cf/priv/limitations.yaml @@ -7,6 +7,7 @@ create: statement: [ 0 , 3 , 6 , 12 , 15 , 25 , 30 , 30 , 30 ] speaker: [ 0 , 0 , 0 , 3 , 6 , 15 , 30 , 40 , 50 ] add: + unlisted_video: [ 0 , 0 , 1 , 1 , 1 , 2 , 3 , 5 , 10 ] video: [ 0 , 0 , 0 , 0 , 1 , 2 , 3 , 5 , 10 ] speaker: [ 0 , 0 , 0 , 3 , 6 , 15 , 30 , 40 , 50 ] update: diff --git a/apps/db/lib/db_type/entity.ex b/apps/db/lib/db_type/entity.ex index 9baffe67..db12a903 100644 --- a/apps/db/lib/db_type/entity.ex +++ b/apps/db/lib/db_type/entity.ex @@ -8,5 +8,6 @@ defenum( comment: 4, fact: 5, user_action: 6, - user: 7 + user: 7, + unlisted_video: 8 )