CommonAPI: Create profile updates as public.

This saves us lots of sending out because we can use sharedInbox.
This commit is contained in:
lain 2019-10-05 14:53:50 +02:00 committed by Ariadne Conill
parent 4d85e07e9e
commit b97a7709c7
2 changed files with 8 additions and 2 deletions

View File

@ -17,6 +17,8 @@ defmodule Pleroma.Web.CommonAPI do
import Pleroma.Web.Gettext import Pleroma.Web.Gettext
import Pleroma.Web.CommonAPI.Utils import Pleroma.Web.CommonAPI.Utils
require Pleroma.Constants
def follow(follower, followed) do def follow(follower, followed) do
with {:ok, follower} <- User.maybe_direct_follow(follower, followed), with {:ok, follower} <- User.maybe_direct_follow(follower, followed),
{:ok, activity} <- ActivityPub.follow(follower, followed), {:ok, activity} <- ActivityPub.follow(follower, followed),
@ -316,7 +318,7 @@ def update(user) do
ActivityPub.update(%{ ActivityPub.update(%{
local: true, local: true,
to: [user.follower_address], to: [Pleroma.Constants.as_public(), user.follower_address],
cc: [], cc: [],
actor: user.ap_id, actor: user.ap_id,
object: Pleroma.Web.ActivityPub.UserView.render("user.json", %{user: user}) object: Pleroma.Web.ActivityPub.UserView.render("user.json", %{user: user})

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.CommonAPITest do
import Pleroma.Factory import Pleroma.Factory
require Pleroma.Constants
clear_config([:instance, :safe_dm_mentions]) clear_config([:instance, :safe_dm_mentions])
clear_config([:instance, :limit]) clear_config([:instance, :limit])
clear_config([:instance, :max_pinned_statuses]) clear_config([:instance, :max_pinned_statuses])
@ -96,11 +98,13 @@ test "it adds emoji in the object" do
test "it adds emoji when updating profiles" do test "it adds emoji when updating profiles" do
user = insert(:user, %{name: ":firefox:"}) user = insert(:user, %{name: ":firefox:"})
CommonAPI.update(user) {:ok, activity} = CommonAPI.update(user)
user = User.get_cached_by_ap_id(user.ap_id) user = User.get_cached_by_ap_id(user.ap_id)
[firefox] = user.info.source_data["tag"] [firefox] = user.info.source_data["tag"]
assert firefox["name"] == ":firefox:" assert firefox["name"] == ":firefox:"
assert Pleroma.Constants.as_public() in activity.recipients
end end
describe "posting" do describe "posting" do