aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2018-11-06 19:34:57 +0100
committerhref <href@random.sh>2018-11-06 19:41:15 +0100
commit5bb88fd1749931e755157760ec833c5d50ebb8c8 (patch)
treea43e1d2cb7812bd8df741203126e1ca12052c058 /lib/pleroma/web/common_api/common_api.ex
parent25512aa29cae22b73ee45a22954693c1a130ea3e (diff)
downloadpleroma-5bb88fd1749931e755157760ec833c5d50ebb8c8.tar.gz
Runtime configuration
Related to #85 Everything should now be configured at runtime, with the exception of the `Pleroma.HTML` scrubbers (the scrubbers used can be changed at runtime, but their configuration is compile-time) because it's building a module with a macro.
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 8f47bb127..77e4dbbd7 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -70,15 +70,17 @@ 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"
+ defp get_content_type(content_type) do
+ if Enum.member?(Pleroma.Config.get([:instance, :allowed_post_formats]), content_type) do
+ content_type
+ else
+ "text/plain"
+ end
+ end
- @limit Keyword.get(@instance, :limit)
def post(user, %{"status" => status} = data) do
visibility = get_visibility(data)
+ limit = Pleroma.Config.get([:instance, :limit])
with status <- String.trim(status),
attachments <- attachments_from_ids(data["media_ids"]),
@@ -98,7 +100,7 @@ defmodule Pleroma.Web.CommonAPI do
context <- make_context(inReplyTo),
cw <- data["spoiler_text"],
full_payload <- String.trim(status <> (data["spoiler_text"] || "")),
- length when length in 1..@limit <- String.length(full_payload),
+ length when length in 1..limit <- String.length(full_payload),
object <-
make_note_data(
user.ap_id,