Commit 17f7c5e2 authored by rinpatch's avatar rinpatch
Browse files

Merge branch 'fix/unfollows-not-working' into 'develop'

Normalize the object in `create_or_bump_for` only after ensuring the activity type is Create

Closes #874

See merge request pleroma/pleroma!1138
parents 3ded9952 15cda998
Pipeline #11693 passed with stages
in 5 minutes
......@@ -47,8 +47,8 @@ def get_for_ap_id(ap_id) do
def create_or_bump_for(activity) do
with true <- Pleroma.Web.ActivityPub.Visibility.is_direct?(activity),
object <- Pleroma.Object.normalize(activity),
"Create" <-["type"],
object <- Pleroma.Object.normalize(activity),
"Note" <-["type"],
ap_id when is_binary(ap_id) and byte_size(ap_id) > 0 <-["context"] do
{:ok, conversation} = create_for_ap_id(ap_id)
......@@ -4,7 +4,9 @@
defmodule Pleroma.ConversationTest do
use Pleroma.DataCase
alias Pleroma.Activity
alias Pleroma.Conversation
alias Pleroma.Object
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
......@@ -134,4 +136,40 @@ test "create_or_bump_for returns the conversation with participations" do
assert {:error, _} = Conversation.create_or_bump_for(activity)
test "create_or_bump_for does not normalize objects before checking the activity type" do
note = insert(:note)
note_id =["id"]
refute Object.get_by_ap_id(note_id)
Tesla.Mock.mock(fn env ->
case env.url do
^note_id ->
# TODO: add attributedTo and tag to the note factory
body =
|> Map.put("attributedTo",["actor"])
|> Map.put("tag", [])
|> Jason.encode!()
%Tesla.Env{status: 200, body: body}
undo = %Activity{
id: "fake",
data: %{
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
"actor" =>["actor"],
"to" => [["actor"]],
"object" => note_id,
"type" => "Undo"
refute Object.get_by_ap_id(note_id)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment