logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

only_media.ex (558B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Upload.Filter.OnlyMedia do
  5. @behaviour Pleroma.Upload.Filter
  6. alias Pleroma.Upload
  7. def filter(%Upload{content_type: content_type}) do
  8. [type, _subtype] = String.split(content_type, "/")
  9. if type in ["image", "video", "audio"] do
  10. {:ok, :noop}
  11. else
  12. {:error, "Disallowed content-type: #{content_type}"}
  13. end
  14. end
  15. def filter(_), do: {:ok, :noop}
  16. end