diff options
author | Alex Gleason <alex@alexgleason.me> | 2020-07-16 14:51:36 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2020-07-16 14:51:36 -0500 |
commit | 38425ebdbf157377ccb0402f78dc3d02f81c55f5 (patch) | |
tree | 740f32837d28e918f097c948d89827d99434d5b2 /lib/pleroma/web/common_api/common_api.ex | |
parent | 8daacc911498d827fd68ea3d34eb1be9ae4a1ffe (diff) | |
parent | 3a2b2cb6f2d6ce39ae0d246649189c021c535992 (diff) | |
download | pleroma-38425ebdbf157377ccb0402f78dc3d02f81c55f5.tar.gz |
Merge remote-tracking branch 'upstream/develop' into linkify
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 04e081a8e..4d5b0decf 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -25,6 +25,13 @@ defmodule Pleroma.Web.CommonAPI do require Pleroma.Constants require Logger + def block(blocker, blocked) do + with {:ok, block_data, _} <- Builder.block(blocker, blocked), + {:ok, block, _} <- Pipeline.common_pipeline(block_data, local: true) do + {:ok, block} + end + end + def post_chat_message(%User{} = user, %User{} = recipient, content, opts \\ []) do with maybe_attachment <- opts[:media_id] && Object.get_by_id(opts[:media_id]), :ok <- validate_chat_content_length(content, !!maybe_attachment), @@ -94,10 +101,14 @@ defmodule Pleroma.Web.CommonAPI do def follow(follower, followed) do timeout = Pleroma.Config.get([:activitypub, :follow_handshake_timeout]) - with {:ok, follower} <- User.maybe_direct_follow(follower, followed), - {:ok, activity} <- ActivityPub.follow(follower, followed), + with {:ok, follow_data, _} <- Builder.follow(follower, followed), + {:ok, activity, _} <- Pipeline.common_pipeline(follow_data, local: true), {:ok, follower, followed} <- User.wait_and_refresh(timeout, follower, followed) do - {:ok, follower, followed, activity} + if activity.data["state"] == "reject" do + {:error, :rejected} + else + {:ok, follower, followed, activity} + end end end |