aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/upload/filter/only_media.ex
blob: a9caeba67e8cc9c161cf202b3364f2e8d3436938 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Pleroma: A lightweight social networking server
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Upload.Filter.OnlyMedia do
  @behaviour Pleroma.Upload.Filter
  alias Pleroma.Upload

  def filter(%Upload{content_type: content_type}) do
    [type, _subtype] = String.split(content_type, "/")

    if type in ["image", "video", "audio"] do
      {:ok, :noop}
    else
      {:error, "Disallowed content-type: #{content_type}"}
    end
  end

  def filter(_), do: {:ok, :noop}
end