aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorHakaba Hitoyo <hakabahitoyo@example.com>2018-11-15 14:04:09 +0900
committerHakaba Hitoyo <hakabahitoyo@example.com>2018-11-15 14:04:09 +0900
commit5c8b8f6cb7212bd202924b535cd2a263416e78d4 (patch)
tree07ad2b2dd44189ae14a1ff44ff5a98013143866b /lib/pleroma/web/common_api/common_api.ex
parent3484f687958f57ea5ce749135f78517ff12849d7 (diff)
parentcc45797f4e1765f5123c058166f6032c6a6556a0 (diff)
downloadpleroma-5c8b8f6cb7212bd202924b535cd2a263416e78d4.tar.gz
Merge remote-tracking branch 'official/develop' into develop
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index f8fef219f..77e4dbbd7 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -36,7 +36,6 @@ defmodule Pleroma.Web.CommonAPI do
def favorite(id_or_ap_id, user) do
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
- false <- activity.data["actor"] == user.ap_id,
object <- Object.normalize(activity.data["object"]["id"]) do
ActivityPub.like(user, object)
else
@@ -47,7 +46,6 @@ defmodule Pleroma.Web.CommonAPI do
def unfavorite(id_or_ap_id, user) do
with %Activity{} = activity <- get_by_id_or_ap_id(id_or_ap_id),
- false <- activity.data["actor"] == user.ap_id,
object <- Object.normalize(activity.data["object"]["id"]) do
ActivityPub.unlike(user, object)
else
@@ -72,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"]),
@@ -100,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,