alias Pleroma.User
alias Pleroma.Web.ActivityPub.MRF
alias Pleroma.Web.ActivityPub.Transmogrifier
+ alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Streamer
alias Pleroma.Web.WebFinger
alias Pleroma.Workers.BackgroundWorker
end
def update(%{to: to, cc: cc, actor: actor, object: object} = params) do
- # only accept false as false value
local = !(params[:local] == false)
+ activity_id = params[:activity_id]
with data <- %{
"to" => to,
"actor" => actor,
"object" => object
},
+ data <- Utils.maybe_put(data, "id", activity_id),
{:ok, activity} <- insert(data, local),
:ok <- maybe_federate(activity) do
{:ok, activity}
to: data["to"] || [],
cc: data["cc"] || [],
object: object,
- actor: actor_id
+ actor: actor_id,
+ activity_id: data["id"]
})
else
e ->
|> Repo.all()
end
- defp maybe_put(map, _key, nil), do: map
- defp maybe_put(map, key, value), do: Map.put(map, key, value)
+ def maybe_put(map, _key, nil), do: map
+ def maybe_put(map, key, value), do: Map.put(map, key, value)
end
import Pleroma.Web.Gettext
import Pleroma.Web.CommonAPI.Utils
+ require Pleroma.Constants
+
def follow(follower, followed) do
timeout = Pleroma.Config.get([:activitypub, :follow_handshake_timeout])
ActivityPub.update(%{
local: true,
- to: [user.follower_address],
+ to: [Pleroma.Constants.as_public(), user.follower_address],
cc: [],
actor: user.ap_id,
object: Pleroma.Web.ActivityPub.UserView.render("user.json", %{user: user})
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(update_data)
+ assert data["id"] == update_data["id"]
+
user = User.get_cached_by_ap_id(data["actor"])
assert user.name == "gargle"
import Pleroma.Factory
+ require Pleroma.Constants
+
clear_config([:instance, :safe_dm_mentions])
clear_config([:instance, :limit])
clear_config([:instance, :max_pinned_statuses])
test "it adds emoji when updating profiles" do
user = insert(:user, %{name: ":firefox:"})
- CommonAPI.update(user)
+ {:ok, activity} = CommonAPI.update(user)
user = User.get_cached_by_ap_id(user.ap_id)
[firefox] = user.info.source_data["tag"]
assert firefox["name"] == ":firefox:"
+
+ assert Pleroma.Constants.as_public() in activity.recipients
end
describe "posting" do