Remove MDII uploader
This commit is contained in:
parent
05ca420c09
commit
0c9c62509d
@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
### Removed
|
### Removed
|
||||||
- **Breaking**: Removed 1.0+ deprecated configurations `Pleroma.Upload, :strip_exif` and `:instance, :dedupe_media`
|
- **Breaking**: Removed 1.0+ deprecated configurations `Pleroma.Upload, :strip_exif` and `:instance, :dedupe_media`
|
||||||
- **Breaking**: OStatus protocol support
|
- **Breaking**: OStatus protocol support
|
||||||
|
- **Breaking**: MDII uploader
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- **Breaking:** Elixir >=1.8 is now required (was >= 1.7)
|
- **Breaking:** Elixir >=1.8 is now required (was >= 1.7)
|
||||||
|
@ -108,10 +108,6 @@ config :pleroma, Pleroma.Uploaders.S3,
|
|||||||
streaming_enabled: true,
|
streaming_enabled: true,
|
||||||
public_endpoint: "https://s3.amazonaws.com"
|
public_endpoint: "https://s3.amazonaws.com"
|
||||||
|
|
||||||
config :pleroma, Pleroma.Uploaders.MDII,
|
|
||||||
cgi: "https://mdii.sakura.ne.jp/mdii-post.cgi",
|
|
||||||
files: "https://mdii.sakura.ne.jp"
|
|
||||||
|
|
||||||
config :pleroma, :emoji,
|
config :pleroma, :emoji,
|
||||||
shortcode_globs: ["/emoji/custom/**/*.png"],
|
shortcode_globs: ["/emoji/custom/**/*.png"],
|
||||||
pack_extensions: [".png", ".gif"],
|
pack_extensions: [".png", ".gif"],
|
||||||
|
@ -2557,23 +2557,6 @@ config :pleroma, :config_description, [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
%{
|
|
||||||
group: :pleroma,
|
|
||||||
key: Pleroma.Uploaders.MDII,
|
|
||||||
type: :group,
|
|
||||||
children: [
|
|
||||||
%{
|
|
||||||
key: :cgi,
|
|
||||||
type: :string,
|
|
||||||
suggestions: ["https://mdii.sakura.ne.jp/mdii-post.cgi"]
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
key: :files,
|
|
||||||
type: :string,
|
|
||||||
suggestions: ["https://mdii.sakura.ne.jp"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
%{
|
%{
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :http,
|
key: :http,
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
defmodule Pleroma.Uploaders.MDII do
|
|
||||||
@moduledoc "Represents uploader for https://github.com/hakaba-hitoyo/minimal-digital-image-infrastructure"
|
|
||||||
|
|
||||||
alias Pleroma.Config
|
|
||||||
alias Pleroma.HTTP
|
|
||||||
|
|
||||||
@behaviour Pleroma.Uploaders.Uploader
|
|
||||||
|
|
||||||
# MDII-hosted images are never passed through the MediaPlug; only local media.
|
|
||||||
# Delegate to Pleroma.Uploaders.Local
|
|
||||||
def get_file(file) do
|
|
||||||
Pleroma.Uploaders.Local.get_file(file)
|
|
||||||
end
|
|
||||||
|
|
||||||
def put_file(upload) do
|
|
||||||
cgi = Config.get([Pleroma.Uploaders.MDII, :cgi])
|
|
||||||
files = Config.get([Pleroma.Uploaders.MDII, :files])
|
|
||||||
|
|
||||||
{:ok, file_data} = File.read(upload.tempfile)
|
|
||||||
|
|
||||||
extension = String.split(upload.name, ".") |> List.last()
|
|
||||||
query = "#{cgi}?#{extension}"
|
|
||||||
|
|
||||||
with {:ok, %{status: 200, body: body}} <-
|
|
||||||
HTTP.post(query, file_data, [], adapter: [pool: :default]) do
|
|
||||||
remote_file_name = String.split(body) |> List.first()
|
|
||||||
public_url = "#{files}/#{remote_file_name}.#{extension}"
|
|
||||||
{:ok, {:url, public_url}}
|
|
||||||
else
|
|
||||||
_ -> Pleroma.Uploaders.Local.put_file(upload)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,50 +0,0 @@
|
|||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
defmodule Pleroma.Uploaders.MDIITest do
|
|
||||||
use Pleroma.DataCase
|
|
||||||
alias Pleroma.Uploaders.MDII
|
|
||||||
import Tesla.Mock
|
|
||||||
|
|
||||||
describe "get_file/1" do
|
|
||||||
test "it returns path to local folder for files" do
|
|
||||||
assert MDII.get_file("") == {:ok, {:static_dir, "test/uploads"}}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "put_file/1" do
|
|
||||||
setup do
|
|
||||||
file_upload = %Pleroma.Upload{
|
|
||||||
name: "mdii-image.jpg",
|
|
||||||
content_type: "image/jpg",
|
|
||||||
path: "test_folder/mdii-image.jpg",
|
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
|
||||||
}
|
|
||||||
|
|
||||||
[file_upload: file_upload]
|
|
||||||
end
|
|
||||||
|
|
||||||
test "save file", %{file_upload: file_upload} do
|
|
||||||
mock(fn
|
|
||||||
%{method: :post, url: "https://mdii.sakura.ne.jp/mdii-post.cgi?jpg"} ->
|
|
||||||
%Tesla.Env{status: 200, body: "mdii-image"}
|
|
||||||
end)
|
|
||||||
|
|
||||||
assert MDII.put_file(file_upload) ==
|
|
||||||
{:ok, {:url, "https://mdii.sakura.ne.jp/mdii-image.jpg"}}
|
|
||||||
end
|
|
||||||
|
|
||||||
test "save file to local if MDII isn`t available", %{file_upload: file_upload} do
|
|
||||||
mock(fn
|
|
||||||
%{method: :post, url: "https://mdii.sakura.ne.jp/mdii-post.cgi?jpg"} ->
|
|
||||||
%Tesla.Env{status: 500}
|
|
||||||
end)
|
|
||||||
|
|
||||||
assert MDII.put_file(file_upload) == :ok
|
|
||||||
|
|
||||||
assert Path.join([Pleroma.Uploaders.Local.upload_path(), file_upload.path])
|
|
||||||
|> File.exists?()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user