2020-11-26 11:41:13 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Resolvers.MediaTest do
|
2020-01-26 21:36:50 +01:00
|
|
|
use Mobilizon.Web.ConnCase
|
2019-05-22 14:12:11 +02:00
|
|
|
use Bamboo.Test
|
2020-01-26 20:34:25 +01:00
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
import Mobilizon.Factory
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
alias Mobilizon.Medias.Media
|
2020-01-26 20:34:25 +01:00
|
|
|
|
|
|
|
alias Mobilizon.GraphQL.AbsintheHelpers
|
|
|
|
|
2020-01-28 19:18:33 +01:00
|
|
|
alias Mobilizon.Web.Endpoint
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
@default_media_details %{name: "my pic", alt: "represents something", file: "picture.png"}
|
|
|
|
@default_media_path "test/fixtures/picture.png"
|
2020-11-23 12:31:15 +01:00
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
setup %{conn: conn} do
|
|
|
|
user = insert(:user)
|
2019-05-31 17:58:03 +02:00
|
|
|
actor = insert(:actor, user: user)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2019-05-31 17:58:03 +02:00
|
|
|
{:ok, conn: conn, user: user, actor: actor}
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
@media_query """
|
|
|
|
query Media($id: ID!) {
|
|
|
|
media(id: $id) {
|
2020-11-20 16:35:48 +01:00
|
|
|
id
|
|
|
|
name,
|
|
|
|
alt,
|
|
|
|
url,
|
|
|
|
content_type,
|
|
|
|
size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
@upload_media_mutation """
|
|
|
|
mutation UploadMedia($name: String!, $alt: String, $file: Upload!) {
|
|
|
|
uploadMedia(
|
2020-11-23 12:31:15 +01:00
|
|
|
name: $name
|
|
|
|
alt: $alt
|
|
|
|
file: $file
|
|
|
|
) {
|
|
|
|
url
|
|
|
|
name
|
|
|
|
content_type
|
|
|
|
size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
describe "Resolver: Get media" do
|
|
|
|
test "media/3 returns the information on a media", %{conn: conn} do
|
|
|
|
%Media{id: id} = media = insert(:media)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
res =
|
2020-11-20 16:35:48 +01:00
|
|
|
conn
|
2020-11-26 11:41:13 +01:00
|
|
|
|> AbsintheHelpers.graphql_query(query: @media_query, variables: %{id: id})
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["media"]["name"] == media.file.name
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["media"]["content_type"] ==
|
|
|
|
media.file.content_type
|
2019-06-03 17:13:47 +02:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["media"]["size"] == 13_120
|
2019-06-03 17:13:47 +02:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["media"]["url"] =~ Endpoint.url()
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
test "media/3 returns nothing on a non-existent media", %{conn: conn} do
|
2019-05-22 14:12:11 +02:00
|
|
|
res =
|
2020-11-20 16:35:48 +01:00
|
|
|
conn
|
2020-11-26 11:41:13 +01:00
|
|
|
|> AbsintheHelpers.graphql_query(query: @media_query, variables: %{id: 3})
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2020-11-20 16:35:48 +01:00
|
|
|
assert hd(res["errors"])["message"] == "Resource not found"
|
|
|
|
assert hd(res["errors"])["status_code"] == 404
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
describe "Resolver: Upload media" do
|
|
|
|
test "upload_media/3 uploads a new media", %{conn: conn, user: user} do
|
|
|
|
media = %{name: "my pic", alt: "represents something", file: "picture.png"}
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
map = %{
|
2020-11-26 11:41:13 +01:00
|
|
|
"query" => @upload_media_mutation,
|
|
|
|
"variables" => media,
|
|
|
|
media.file => %Plug.Upload{
|
2019-05-22 14:12:11 +02:00
|
|
|
path: "test/fixtures/picture.png",
|
2020-11-26 11:41:13 +01:00
|
|
|
filename: media.file
|
2019-05-22 14:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> put_req_header("content-type", "multipart/form-data")
|
|
|
|
|> post(
|
|
|
|
"/api",
|
|
|
|
map
|
|
|
|
)
|
2020-11-20 16:35:48 +01:00
|
|
|
|> json_response(200)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["uploadMedia"]["name"] == media.name
|
|
|
|
assert res["data"]["uploadMedia"]["content_type"] == "image/png"
|
|
|
|
assert res["data"]["uploadMedia"]["size"] == 10_097
|
|
|
|
assert res["data"]["uploadMedia"]["url"]
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
test "upload_media/3 forbids uploading if no auth", %{conn: conn} do
|
|
|
|
media = %{name: "my pic", alt: "represents something", file: "picture.png"}
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
map = %{
|
2020-11-26 11:41:13 +01:00
|
|
|
"query" => @upload_media_mutation,
|
|
|
|
"variables" => media,
|
|
|
|
media.file => %Plug.Upload{
|
2019-05-22 14:12:11 +02:00
|
|
|
path: "test/fixtures/picture.png",
|
2020-11-26 11:41:13 +01:00
|
|
|
filename: media.file
|
2019-05-22 14:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> put_req_header("content-type", "multipart/form-data")
|
|
|
|
|> post(
|
|
|
|
"/api",
|
|
|
|
map
|
|
|
|
)
|
2020-11-20 16:35:48 +01:00
|
|
|
|> json_response(200)
|
|
|
|
|
|
|
|
assert hd(res["errors"])["message"] == "You need to be logged in"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
describe "Resolver: Remove media" do
|
|
|
|
@remove_media_mutation """
|
|
|
|
mutation RemoveMedia($id: ID!) {
|
|
|
|
removeMedia(id: $id) {
|
2020-11-20 16:35:48 +01:00
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
test "Removes a previously uploaded media", %{conn: conn, user: user, actor: actor} do
|
|
|
|
%Media{id: media_id} = insert(:media, actor: actor)
|
2020-11-20 16:35:48 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
2020-11-26 11:41:13 +01:00
|
|
|
query: @remove_media_mutation,
|
|
|
|
variables: %{id: media_id}
|
2020-11-20 16:35:48 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert is_nil(res["errors"])
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["removeMedia"]["id"] == to_string(media_id)
|
2020-11-20 16:35:48 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2020-11-26 11:41:13 +01:00
|
|
|
|> AbsintheHelpers.graphql_query(query: @media_query, variables: %{id: media_id})
|
2020-11-20 16:35:48 +01:00
|
|
|
|
|
|
|
assert hd(res["errors"])["message"] == "Resource not found"
|
|
|
|
assert hd(res["errors"])["status_code"] == 404
|
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
test "Removes nothing if media is not found", %{conn: conn, user: user} do
|
2020-11-20 16:35:48 +01:00
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
2020-11-26 11:41:13 +01:00
|
|
|
query: @remove_media_mutation,
|
2020-11-20 16:35:48 +01:00
|
|
|
variables: %{id: 400}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert hd(res["errors"])["message"] == "Resource not found"
|
|
|
|
assert hd(res["errors"])["status_code"] == 404
|
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
test "Removes nothing if media if not logged-in", %{conn: conn, actor: actor} do
|
|
|
|
%Media{id: media_id} = insert(:media, actor: actor)
|
2020-11-20 16:35:48 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
2020-11-26 11:41:13 +01:00
|
|
|
query: @remove_media_mutation,
|
|
|
|
variables: %{id: media_id}
|
2020-11-20 16:35:48 +01:00
|
|
|
)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
2020-11-20 16:35:48 +01:00
|
|
|
assert hd(res["errors"])["message"] == "You need to be logged in"
|
|
|
|
assert hd(res["errors"])["status_code"] == 401
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
end
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
describe "Resolver: Get actor media size" do
|
|
|
|
@actor_media_size_query """
|
|
|
|
query LoggedPerson {
|
|
|
|
loggedPerson {
|
|
|
|
id
|
|
|
|
mediaSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
test "with own actor", %{conn: conn} do
|
|
|
|
user = insert(:user)
|
|
|
|
insert(:actor, user: user)
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @actor_media_size_query)
|
|
|
|
|
|
|
|
assert res["data"]["loggedPerson"]["mediaSize"] == 0
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
res = upload_media(conn, user)
|
|
|
|
assert res["data"]["uploadMedia"]["size"] == 10_097
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @actor_media_size_query)
|
|
|
|
|
|
|
|
assert res["data"]["loggedPerson"]["mediaSize"] == 10_097
|
|
|
|
|
|
|
|
res =
|
2020-11-26 11:41:13 +01:00
|
|
|
upload_media(
|
2020-11-23 12:31:15 +01:00
|
|
|
conn,
|
|
|
|
user,
|
|
|
|
"test/fixtures/image.jpg",
|
2020-11-26 11:41:13 +01:00
|
|
|
Map.put(@default_media_details, :file, "image.jpg")
|
2020-11-23 12:31:15 +01:00
|
|
|
)
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["uploadMedia"]["size"] == 13_227
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @actor_media_size_query)
|
|
|
|
|
|
|
|
assert res["data"]["loggedPerson"]["mediaSize"] == 23_324
|
|
|
|
end
|
|
|
|
|
|
|
|
@list_actors_query """
|
|
|
|
query ListPersons($preferredUsername: String) {
|
|
|
|
persons(preferredUsername: $preferredUsername) {
|
|
|
|
total,
|
|
|
|
elements {
|
|
|
|
id
|
|
|
|
mediaSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
test "as a moderator", %{conn: conn} do
|
|
|
|
moderator = insert(:user, role: :moderator)
|
|
|
|
user = insert(:user)
|
|
|
|
actor = insert(:actor, user: user)
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(moderator)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @list_actors_query,
|
|
|
|
variables: %{preferredUsername: actor.preferred_username}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert is_nil(res["errors"])
|
|
|
|
assert hd(res["data"]["persons"]["elements"])["mediaSize"] == 0
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
upload_media(conn, user)
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(moderator)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @list_actors_query,
|
|
|
|
variables: %{preferredUsername: actor.preferred_username}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert is_nil(res["errors"])
|
|
|
|
assert hd(res["data"]["persons"]["elements"])["mediaSize"] == 10_097
|
|
|
|
end
|
|
|
|
|
|
|
|
@event_organizer_media_query """
|
|
|
|
query Event($uuid: UUID!) {
|
|
|
|
event(uuid: $uuid) {
|
|
|
|
id
|
|
|
|
organizerActor {
|
|
|
|
id
|
|
|
|
mediaSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
test "as a different user", %{conn: conn} do
|
|
|
|
user = insert(:user)
|
|
|
|
event = insert(:event)
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @event_organizer_media_query,
|
|
|
|
variables: %{uuid: event.uuid}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert hd(res["errors"])["message"] == "unauthorized"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "without being logged-in", %{conn: conn} do
|
|
|
|
event = insert(:event)
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @event_organizer_media_query,
|
|
|
|
variables: %{uuid: event.uuid}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert hd(res["errors"])["message"] == "unauthenticated"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "Resolver: Get user media size" do
|
|
|
|
@user_media_size_query """
|
|
|
|
query LoggedUser {
|
|
|
|
loggedUser {
|
|
|
|
id
|
|
|
|
mediaSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
@change_default_actor_mutation """
|
|
|
|
mutation ChangeDefaultActor($preferredUsername: String!) {
|
|
|
|
changeDefaultActor(preferredUsername: $preferredUsername) {
|
|
|
|
defaultActor {
|
|
|
|
id
|
|
|
|
preferredUsername
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
test "with own user", %{conn: conn} do
|
|
|
|
user = insert(:user)
|
|
|
|
insert(:actor, user: user)
|
|
|
|
actor_2 = insert(:actor, user: user)
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @user_media_size_query)
|
|
|
|
|
|
|
|
assert res["errors"] == nil
|
|
|
|
assert res["data"]["loggedUser"]["mediaSize"] == 0
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
res = upload_media(conn, user)
|
|
|
|
assert res["data"]["uploadMedia"]["size"] == 10_097
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @user_media_size_query)
|
|
|
|
|
|
|
|
assert res["data"]["loggedUser"]["mediaSize"] == 10_097
|
|
|
|
|
|
|
|
res =
|
2020-11-26 11:41:13 +01:00
|
|
|
upload_media(
|
2020-11-23 12:31:15 +01:00
|
|
|
conn,
|
|
|
|
user,
|
|
|
|
"test/fixtures/image.jpg",
|
2020-11-26 11:41:13 +01:00
|
|
|
Map.put(@default_media_details, :file, "image.jpg")
|
2020-11-23 12:31:15 +01:00
|
|
|
)
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["uploadMedia"]["size"] == 13_227
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @user_media_size_query)
|
|
|
|
|
|
|
|
assert res["data"]["loggedUser"]["mediaSize"] == 23_324
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @change_default_actor_mutation,
|
|
|
|
variables: %{preferredUsername: actor_2.preferred_username}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert is_nil(res["errors"])
|
|
|
|
|
|
|
|
res =
|
2020-11-26 11:41:13 +01:00
|
|
|
upload_media(
|
2020-11-23 12:31:15 +01:00
|
|
|
conn,
|
|
|
|
user,
|
|
|
|
"test/fixtures/image.jpg",
|
2020-11-26 11:41:13 +01:00
|
|
|
Map.put(@default_media_details, :file, "image.jpg")
|
2020-11-23 12:31:15 +01:00
|
|
|
)
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["uploadMedia"]["size"] == 13_227
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @user_media_size_query)
|
|
|
|
|
|
|
|
assert res["data"]["loggedUser"]["mediaSize"] == 36_551
|
|
|
|
end
|
|
|
|
|
|
|
|
@list_users_query """
|
|
|
|
query ListUsers($email: String) {
|
|
|
|
users(email: $email) {
|
|
|
|
total,
|
|
|
|
elements {
|
|
|
|
id
|
|
|
|
mediaSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
test "as a moderator", %{conn: conn} do
|
|
|
|
moderator = insert(:user, role: :moderator)
|
|
|
|
user = insert(:user)
|
|
|
|
insert(:actor, user: user)
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(moderator)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @list_users_query,
|
|
|
|
variables: %{email: user.email}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert is_nil(res["errors"])
|
|
|
|
assert hd(res["data"]["users"]["elements"])["mediaSize"] == 0
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
res = upload_media(conn, user)
|
2020-11-23 12:31:15 +01:00
|
|
|
assert is_nil(res["errors"])
|
2020-11-26 11:41:13 +01:00
|
|
|
assert res["data"]["uploadMedia"]["size"] == 10_097
|
2020-11-23 12:31:15 +01:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> auth_conn(moderator)
|
|
|
|
|> AbsintheHelpers.graphql_query(
|
|
|
|
query: @list_users_query,
|
|
|
|
variables: %{email: user.email}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert is_nil(res["errors"])
|
|
|
|
assert hd(res["data"]["users"]["elements"])["mediaSize"] == 10_097
|
|
|
|
end
|
|
|
|
|
|
|
|
test "without being logged-in", %{conn: conn} do
|
|
|
|
res =
|
|
|
|
conn
|
|
|
|
|> AbsintheHelpers.graphql_query(query: @user_media_size_query)
|
|
|
|
|
2020-11-30 16:14:13 +01:00
|
|
|
assert hd(res["errors"])["message"] == "You need to be logged in"
|
2020-11-23 12:31:15 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-26 11:41:13 +01:00
|
|
|
@spec upload_media(Plug.Conn.t(), Mobilizon.Users.User.t(), String.t(), map()) :: map()
|
|
|
|
defp upload_media(
|
2020-11-23 12:31:15 +01:00
|
|
|
conn,
|
|
|
|
user,
|
2020-11-26 11:41:13 +01:00
|
|
|
media_path \\ @default_media_path,
|
|
|
|
media_details \\ @default_media_details
|
2020-11-23 12:31:15 +01:00
|
|
|
) do
|
|
|
|
map = %{
|
2020-11-26 11:41:13 +01:00
|
|
|
"query" => @upload_media_mutation,
|
|
|
|
"variables" => media_details,
|
|
|
|
media_details.file => %Plug.Upload{
|
|
|
|
path: media_path,
|
|
|
|
filename: media_details.file
|
2020-11-23 12:31:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
conn
|
|
|
|
|> auth_conn(user)
|
|
|
|
|> put_req_header("content-type", "multipart/form-data")
|
|
|
|
|> post(
|
|
|
|
"/api",
|
|
|
|
map
|
|
|
|
)
|
|
|
|
|> json_response(200)
|
|
|
|
end
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|