X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fcommon_api%2Fcommon_api.ex;h=77e4dbbd708057e55a9dbee8226efd5761cf5ce5;hb=b4bd5e40e491c8b777c75ec4f096c0c466a6b4e2;hp=2ab50c9682be485489ac21d94bdde4133da04c5d;hpb=a26d5e6b2aba5010c699df659d63048957b347a5;p=akkoma diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 2ab50c968..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,13 +70,19 @@ defmodule Pleroma.Web.CommonAPI do def get_visibility(_), do: "public" - @instance Application.get_env(:pleroma, :instance) - @limit Keyword.get(@instance, :limit) + 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 + def post(user, %{"status" => status} = data) do visibility = get_visibility(data) + limit = Pleroma.Config.get([:instance, :limit]) with status <- String.trim(status), - length when length in 1..@limit <- String.length(status), attachments <- attachments_from_ids(data["media_ids"]), mentions <- Formatter.parse_mentions(status), inReplyTo <- get_replied_to_activity(data["in_reply_to_status_id"]), @@ -90,11 +94,13 @@ 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), cw <- data["spoiler_text"], + full_payload <- String.trim(status <> (data["spoiler_text"] || "")), + length when length in 1..limit <- String.length(full_payload), object <- make_note_data( user.ap_id,