aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-10-05 21:02:17 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-10-05 21:02:17 +0000
commit285ac80c36cbd943b16eb5e1ee4447376f8f555f (patch)
tree3d4e3580f559a5c18efdafbd911e13512439fabd
parent52b05137c5800186fffee83950c83194a3468057 (diff)
downloadpleroma-285ac80c36cbd943b16eb5e1ee4447376f8f555f.tar.gz
config: allow for accepted post formats to be configured
-rw-r--r--config/config.exs7
-rw-r--r--lib/pleroma/web/common_api/common_api.ex7
2 files changed, 12 insertions, 2 deletions
diff --git a/config/config.exs b/config/config.exs
index c3094eb2b..608c035b0 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -74,7 +74,12 @@ config :pleroma, :instance,
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
public: true,
quarantined_instances: [],
- managed_config: true
+ managed_config: true,
+ allowed_post_formats: [
+ "text/plain",
+ "text/html",
+ "text/markdown"
+ ]
config :pleroma, :markup,
# XXX - unfortunately, inline images must be enabled by default right now, because
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 2ab50c968..d4a973e36 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -73,6 +73,11 @@ defmodule Pleroma.Web.CommonAPI do
def get_visibility(_), do: "public"
@instance Application.get_env(:pleroma, :instance)
+ @allowed_post_formats Keyword.get(@instance, :allowed_post_formats)
+
+ defp get_content_type(content_type) when content_type in @allowed_post_formats, do: content_type
+ defp get_content_type(_), do: "text/plain"
+
@limit Keyword.get(@instance, :limit)
def post(user, %{"status" => status} = data) do
visibility = get_visibility(data)
@@ -90,7 +95,7 @@ defmodule Pleroma.Web.CommonAPI do
mentions,
attachments,
tags,
- data["content_type"] || "text/plain",
+ get_content_type(data["content_type"]),
data["no_attachment_links"]
),
context <- make_context(inReplyTo),