Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ end
config :streamshore, Streamshore.Guardian, secret_key: guardian_secret

config :streamshore,
:mailer_enabled,
not is_nil(email_key) and not is_nil(email_address)
:mailer_enabled,
not is_nil(email_key) and not is_nil(email_address)

config :streamshore, :mailer_from_address, email_address

Expand Down
5 changes: 4 additions & 1 deletion lib/streamshore/accounts/favorites.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ defmodule Streamshore.Favorites do
favorite
|> cast(params, [:user, :room])
|> validate_required([:user, :room])
|> unique_constraint(:room, name: :favorites_user_room_index, message: "Room is already a favorite room")
|> unique_constraint(:room,
name: :favorites_user_room_index,
message: "Room is already a favorite room"
)
end
end
5 changes: 4 additions & 1 deletion lib/streamshore/accounts/playlist.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ defmodule Streamshore.Playlist do
playlist
|> cast(params, [:name, :owner])
|> validate_required([:name, :owner])
|> unique_constraint(:name, name: :playlists_owner_name_index, message: "Playlist already exists")
|> unique_constraint(:name,
name: :playlists_owner_name_index,
message: "Playlist already exists"
)
end
end
5 changes: 4 additions & 1 deletion lib/streamshore/accounts/playlist_video.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ defmodule Streamshore.PlaylistVideo do
playlist_video
|> cast(params, [:name, :owner, :video])
|> validate_required([:name, :owner, :video])
|> unique_constraint(:video, name: :playlist_video_owner_name_video_index, message: "Video is already in playlist")
|> unique_constraint(:video,
name: :playlist_video_owner_name_video_index,
message: "Video is already in playlist"
)
end
end
3 changes: 2 additions & 1 deletion lib/streamshore/queue_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ defmodule Streamshore.QueueManager do
{:error, error} -> {:error, :invalid_video, error}
end
else
{:error, :queue_limit, "You already have the maximum allowed amount of videos in the queue."}
{:error, :queue_limit,
"You already have the maximum allowed amount of videos in the queue."}
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/streamshore/videofetcher/videofetcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ defmodule Streamshore.VideoFetcher do
impl().fetch_video(id)
end

defp impl, do: Application.get_env(:streamshore, :video_fetcher, Streamshore.VideoFetcher.Client)
defp impl,
do: Application.get_env(:streamshore, :video_fetcher, Streamshore.VideoFetcher.Client)
end
12 changes: 10 additions & 2 deletions lib/streamshore_web/controllers/favorite_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ defmodule StreamshoreWeb.FavoriteController do

cond do
anon ->
ApiResponses.error(conn, :forbidden, "You must be logged in to add a room to favorites")
ApiResponses.error(
conn,
:forbidden,
"You must be logged in to add a room to favorites"
)

current_user != user ->
ApiResponses.error(conn, :forbidden, "Insufficient permission")
Expand Down Expand Up @@ -90,7 +94,11 @@ defmodule StreamshoreWeb.FavoriteController do

cond do
anon ->
ApiResponses.error(conn, :forbidden, "You must be logged in to remove a room from favorites")
ApiResponses.error(
conn,
:forbidden,
"You must be logged in to remove a room from favorites"
)

current_user != user ->
ApiResponses.error(conn, :forbidden, "Insufficient permission")
Expand Down
12 changes: 6 additions & 6 deletions lib/streamshore_web/controllers/friend_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ defmodule StreamshoreWeb.FriendController do
accepted: 1
})

case Repo.insert(changeset) do
{:ok, _schema} ->
ApiResponses.ok(conn)
case Repo.insert(changeset) do
{:ok, _schema} ->
ApiResponses.ok(conn)

{:error, changeset} ->
ApiResponses.changeset_error(conn, changeset)
end
{:error, changeset} ->
ApiResponses.changeset_error(conn, changeset)
end
else
case Repo.delete(relation) do
{:ok, _schema} ->
Expand Down
12 changes: 10 additions & 2 deletions lib/streamshore_web/controllers/playlist_video_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ defmodule StreamshoreWeb.PlaylistVideoController do

cond do
anon ->
ApiResponses.error(conn, :forbidden, "You must be logged in to add a video to a playlist")
ApiResponses.error(
conn,
:forbidden,
"You must be logged in to add a video to a playlist"
)

user != owner ->
ApiResponses.error(conn, :forbidden, "Insufficient permission")
Expand Down Expand Up @@ -100,7 +104,11 @@ defmodule StreamshoreWeb.PlaylistVideoController do

cond do
anon ->
ApiResponses.error(conn, :forbidden, "You must be logged in to delete a video from a playlist")
ApiResponses.error(
conn,
:forbidden,
"You must be logged in to delete a video from a playlist"
)

user != owner ->
ApiResponses.error(conn, :forbidden, "Insufficient permission")
Expand Down
6 changes: 5 additions & 1 deletion lib/streamshore_web/controllers/session_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ defmodule StreamshoreWeb.SessionController do
String.capitalize(String.trim(random_adjective(), "\r")) <>
String.capitalize(String.trim(random_animal(), "\r"))

ApiResponses.ok(conn, %{token: AuthTokens.create_token(username, true), user: username, anon: true})
ApiResponses.ok(conn, %{
token: AuthTokens.create_token(username, true),
user: username,
anon: true
})
end
end

Expand Down
18 changes: 9 additions & 9 deletions priv/repo/migrations/20200223000712_create_users.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ defmodule Streamshore.Repo.Migrations.CreateUsers do
use Ecto.Migration

def change do
create table(:users) do
add(:username, :string)
add(:email, :string)
add(:password, :string)
add(:room, :string)
add(:admin, :integer)
add(:verify_token, :text)
add(:reset_token, :text)
create table(:users) do
add(:username, :string)
add(:email, :string)
add(:password, :string)
add(:room, :string)
add(:admin, :integer)
add(:verify_token, :text)
add(:reset_token, :text)

timestamps()
timestamps()
end

create(unique_index(:users, [:username]))
Expand Down
3 changes: 1 addition & 2 deletions priv/repo/migrations/20200322033632_friends.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ defmodule Streamshore.Repo.Migrations.Friends do
use Ecto.Migration

def change do
create table(:friends) do
create table(:friends) do
add(:friender, :string)
add(:friendee, :string)
add(:nickname, :string)
add(:accepted, :integer)
end

end
end
3 changes: 1 addition & 2 deletions priv/repo/migrations/20200411231202_add_playlist.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ defmodule Streamshore.Repo.Migrations.AddPlaylist do
use Ecto.Migration

def change do
create table(:playlists) do
create table(:playlists) do
add(:name, :string)
add(:owner, :string)
end

end
end
3 changes: 1 addition & 2 deletions priv/repo/migrations/20200411231215_add_playlist_video.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ defmodule Streamshore.Repo.Migrations.AddPlaylistVideo do
use Ecto.Migration

def change do
create table(:playlist_video) do
create table(:playlist_video) do
add(:name, :string)
add(:owner, :string)
add(:video, :string)
end

end
end
3 changes: 1 addition & 2 deletions priv/repo/migrations/20200412192058_favorites.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ defmodule Streamshore.Repo.Migrations.Favorites do
use Ecto.Migration

def change do
create table(:favorites) do
create table(:favorites) do
add(:user, :string)
add(:room, :string)
end

end
end