From: Thurloat Date: Tue, 28 Aug 2018 01:45:53 +0000 (-0300) Subject: cleaning up a bit. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=0df558a6a5f5a5f64de57c91074981429da08764;p=akkoma cleaning up a bit. --- diff --git a/config/config.exs b/config/config.exs index 4eb59994c..fe4bfe8a0 100644 --- a/config/config.exs +++ b/config/config.exs @@ -11,7 +11,7 @@ config :pleroma, ecto_repos: [Pleroma.Repo] config :pleroma, Pleroma.Repo, types: Pleroma.PostgresTypes config :pleroma, Pleroma.Upload, - uploader: Pleroma.Uploaders.Local + uploader: Pleroma.Uploaders.Local, strip_exif: false config :pleroma, Pleroma.Uploaders.Local, diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index d7cc8122a..e3ad6757b 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -1,6 +1,5 @@ defmodule Pleroma.Upload do alias Ecto.UUID - alias Pleroma.Web def store(%Plug.Upload{} = file, should_dedupe) do settings = Application.get_env(:pleroma, Pleroma.Upload) @@ -26,7 +25,7 @@ defmodule Pleroma.Upload do "name" => name } end - + """ # XXX: does this code actually work? i am skeptical. --kaniini def store(%{"img" => "data:image/" <> image_data}, should_dedupe) do settings = Application.get_env(:pleroma, Pleroma.Upload) @@ -88,11 +87,12 @@ defmodule Pleroma.Upload do "name" => name } end + """ def strip_exif_data(content_type, file) do settings = Application.get_env(:pleroma, Pleroma.Upload) do_strip = Keyword.fetch!(settings, :strip_exif) - [filetype, ext] = String.split(content_type, "/") + [filetype, _ext] = String.split(content_type, "/") if filetype == "image" and do_strip == true do Mogrify.open(file) |> Mogrify.custom("strip") |> Mogrify.save(in_place: true) diff --git a/lib/pleroma/uploaders/local.ex b/lib/pleroma/uploaders/local.ex index 7e5d7a59b..1ba68776f 100644 --- a/lib/pleroma/uploaders/local.ex +++ b/lib/pleroma/uploaders/local.ex @@ -1,7 +1,10 @@ defmodule Pleroma.Uploaders.Local do - def put_file(name, uuid, file, content_type) do - upload_path = get_upload_path(uuid, should_dedupe) + alias Pleroma.Web + + def put_file(name, uuid, file, _content_type, should_dedupe) do + + upload_folder = get_upload_path(uuid, should_dedupe) url_path = get_url(name, uuid, should_dedupe) File.mkdir_p!(upload_folder) diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index 95f20be67..ea9e49cbf 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -1,6 +1,6 @@ defmodule Pleroma.Uploaders.S3 do - def put_file(name, uuid, path, content_type) do + def put_file(name, uuid, path, content_type, _should_dedupe) do settings = Application.get_env(:pleroma, Pleroma.Uploaders.S3) bucket = Keyword.fetch!(settings, :bucket) @@ -12,7 +12,7 @@ defmodule Pleroma.Uploaders.S3 do s3_name = "#{uuid}/#{name}" - {:ok, result} = + {:ok, _} = ExAws.S3.put_object(bucket, s3_name, file_data, [ {:acl, :public_read}, {:content_type, content_type} diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index cbedca004..1e5ac2721 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -11,7 +11,7 @@ defmodule Pleroma.Web.Endpoint do # # You should set gzip to true if you are running phoenix.digest # when deploying your static files in production. - plug(Plug.Static, at: "/media", from: Pleroma.Upload.upload_path(), gzip: false) + plug(Plug.Static, at: "/media", from: Pleroma.Uploaders.Local.upload_path(), gzip: false) plug( Plug.Static,