Merge branch 'refactor/remove-inReplyToStatusId' into 'develop'
Remove inReplyToStatusId See merge request pleroma/pleroma!1062
This commit is contained in:
commit
f896699357
|
@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Link/mention/hashtag detection is now handled by [auto_linker](https://git.pleroma.social/pleroma/auto_linker)
|
- Link/mention/hashtag detection is now handled by [auto_linker](https://git.pleroma.social/pleroma/auto_linker)
|
||||||
- NodeInfo: Return `safe_dm_mentions` feature flag
|
- NodeInfo: Return `safe_dm_mentions` feature flag
|
||||||
- Federation: Expand the audience of delete activities to all recipients of the deleted object
|
- Federation: Expand the audience of delete activities to all recipients of the deleted object
|
||||||
|
- Federation: Removed `inReplyToStatusId` from objects
|
||||||
- Configuration: Dedupe enabled by default
|
- Configuration: Dedupe enabled by default
|
||||||
- Pleroma API: Support for emoji tags in `/api/pleroma/emoji` resulting in a breaking API change
|
- Pleroma API: Support for emoji tags in `/api/pleroma/emoji` resulting in a breaking API change
|
||||||
- Mastodon API: Support for `exclude_types`, `limit` and `min_id` in `/api/v1/notifications`
|
- Mastodon API: Support for `exclude_types`, `limit` and `min_id` in `/api/v1/notifications`
|
||||||
|
|
|
@ -246,20 +246,22 @@ def all_by_actor_and_id(actor, status_ids) do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
def increase_replies_count(id) do
|
def increase_replies_count(nil), do: nil
|
||||||
Activity
|
|
||||||
|> where(id: ^id)
|
def increase_replies_count(object_ap_id) do
|
||||||
|> update([a],
|
from(a in create_by_object_ap_id(object_ap_id),
|
||||||
set: [
|
update: [
|
||||||
data:
|
set: [
|
||||||
fragment(
|
data:
|
||||||
"""
|
fragment(
|
||||||
jsonb_set(?, '{object, repliesCount}',
|
"""
|
||||||
(coalesce((?->'object'->>'repliesCount')::int, 0) + 1)::varchar::jsonb, true)
|
jsonb_set(?, '{object, repliesCount}',
|
||||||
""",
|
(coalesce((?->'object'->>'repliesCount')::int, 0) + 1)::varchar::jsonb, true)
|
||||||
a.data,
|
""",
|
||||||
a.data
|
a.data,
|
||||||
)
|
a.data
|
||||||
|
)
|
||||||
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> Repo.update_all([])
|
|> Repo.update_all([])
|
||||||
|
@ -269,20 +271,22 @@ def increase_replies_count(id) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def decrease_replies_count(id) do
|
def decrease_replies_count(nil), do: nil
|
||||||
Activity
|
|
||||||
|> where(id: ^id)
|
def decrease_replies_count(object_ap_id) do
|
||||||
|> update([a],
|
from(a in create_by_object_ap_id(object_ap_id),
|
||||||
set: [
|
update: [
|
||||||
data:
|
set: [
|
||||||
fragment(
|
data:
|
||||||
"""
|
fragment(
|
||||||
jsonb_set(?, '{object, repliesCount}',
|
"""
|
||||||
(greatest(0, (?->'object'->>'repliesCount')::int - 1))::varchar::jsonb, true)
|
jsonb_set(?, '{object, repliesCount}',
|
||||||
""",
|
(greatest(0, (?->'object'->>'repliesCount')::int - 1))::varchar::jsonb, true)
|
||||||
a.data,
|
""",
|
||||||
a.data
|
a.data,
|
||||||
)
|
a.data
|
||||||
|
)
|
||||||
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> Repo.update_all([])
|
|> Repo.update_all([])
|
||||||
|
|
|
@ -91,12 +91,11 @@ def decrease_note_count_if_public(actor, object) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def increase_replies_count_if_reply(%{
|
def increase_replies_count_if_reply(%{
|
||||||
"object" =>
|
"object" => %{"inReplyTo" => reply_ap_id} = object,
|
||||||
%{"inReplyTo" => reply_ap_id, "inReplyToStatusId" => reply_status_id} = object,
|
|
||||||
"type" => "Create"
|
"type" => "Create"
|
||||||
}) do
|
}) do
|
||||||
if is_public?(object) do
|
if is_public?(object) do
|
||||||
Activity.increase_replies_count(reply_status_id)
|
Activity.increase_replies_count(reply_ap_id)
|
||||||
Object.increase_replies_count(reply_ap_id)
|
Object.increase_replies_count(reply_ap_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -104,10 +103,10 @@ def increase_replies_count_if_reply(%{
|
||||||
def increase_replies_count_if_reply(_create_data), do: :noop
|
def increase_replies_count_if_reply(_create_data), do: :noop
|
||||||
|
|
||||||
def decrease_replies_count_if_reply(%Object{
|
def decrease_replies_count_if_reply(%Object{
|
||||||
data: %{"inReplyTo" => reply_ap_id, "inReplyToStatusId" => reply_status_id} = object
|
data: %{"inReplyTo" => reply_ap_id} = object
|
||||||
}) do
|
}) do
|
||||||
if is_public?(object) do
|
if is_public?(object) do
|
||||||
Activity.decrease_replies_count(reply_status_id)
|
Activity.decrease_replies_count(reply_ap_id)
|
||||||
Object.decrease_replies_count(reply_ap_id)
|
Object.decrease_replies_count(reply_ap_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -225,12 +225,11 @@ def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object)
|
||||||
|
|
||||||
case fetch_obj_helper(in_reply_to_id) do
|
case fetch_obj_helper(in_reply_to_id) do
|
||||||
{:ok, replied_object} ->
|
{:ok, replied_object} ->
|
||||||
with %Activity{} = activity <-
|
with %Activity{} = _activity <-
|
||||||
Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
|
Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
|
||||||
object
|
object
|
||||||
|> Map.put("inReplyTo", replied_object.data["id"])
|
|> Map.put("inReplyTo", replied_object.data["id"])
|
||||||
|> Map.put("inReplyToAtomUri", object["inReplyToAtomUri"] || in_reply_to_id)
|
|> Map.put("inReplyToAtomUri", object["inReplyToAtomUri"] || in_reply_to_id)
|
||||||
|> Map.put("inReplyToStatusId", activity.id)
|
|
||||||
|> Map.put("conversation", replied_object.data["context"] || object["conversation"])
|
|> Map.put("conversation", replied_object.data["context"] || object["conversation"])
|
||||||
|> Map.put("context", replied_object.data["context"] || object["conversation"])
|
|> Map.put("context", replied_object.data["context"] || object["conversation"])
|
||||||
else
|
else
|
||||||
|
|
|
@ -228,7 +228,6 @@ def make_note_data(
|
||||||
if inReplyTo do
|
if inReplyTo do
|
||||||
object
|
object
|
||||||
|> Map.put("inReplyTo", inReplyTo.data["object"]["id"])
|
|> Map.put("inReplyTo", inReplyTo.data["object"]["id"])
|
||||||
|> Map.put("inReplyToStatusId", inReplyTo.id)
|
|
||||||
else
|
else
|
||||||
object
|
object
|
||||||
end
|
end
|
||||||
|
|
|
@ -291,7 +291,7 @@ def render(
|
||||||
"is_local" => activity.local,
|
"is_local" => activity.local,
|
||||||
"is_post_verb" => true,
|
"is_post_verb" => true,
|
||||||
"created_at" => created_at,
|
"created_at" => created_at,
|
||||||
"in_reply_to_status_id" => object["inReplyToStatusId"],
|
"in_reply_to_status_id" => reply_parent && reply_parent.id,
|
||||||
"in_reply_to_screen_name" => reply_user && reply_user.nickname,
|
"in_reply_to_screen_name" => reply_user && reply_user.nickname,
|
||||||
"in_reply_to_profileurl" => User.profile_url(reply_user),
|
"in_reply_to_profileurl" => User.profile_url(reply_user),
|
||||||
"in_reply_to_ostatus_uri" => reply_user && reply_user.ap_id,
|
"in_reply_to_ostatus_uri" => reply_user && reply_user.ap_id,
|
||||||
|
|
|
@ -28,4 +28,18 @@ test "returns the activity that created an object" do
|
||||||
|
|
||||||
assert activity == found_activity
|
assert activity == found_activity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "reply count" do
|
||||||
|
%{id: id, data: %{"object" => %{"id" => object_ap_id}}} = activity = insert(:note_activity)
|
||||||
|
|
||||||
|
replies_count = activity.data["object"]["repliesCount"] || 0
|
||||||
|
expected_increase = replies_count + 1
|
||||||
|
Activity.increase_replies_count(object_ap_id)
|
||||||
|
%{data: %{"object" => %{"repliesCount" => actual_increase}}} = Activity.get_by_id(id)
|
||||||
|
assert expected_increase == actual_increase
|
||||||
|
expected_decrease = expected_increase - 1
|
||||||
|
Activity.decrease_replies_count(object_ap_id)
|
||||||
|
%{data: %{"object" => %{"repliesCount" => actual_decrease}}} = Activity.get_by_id(id)
|
||||||
|
assert expected_decrease == actual_decrease
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,8 +58,6 @@ test "it fetches replied-to activities if we don't have them" do
|
||||||
|
|
||||||
assert returned_activity.data["object"]["inReplyToAtomUri"] ==
|
assert returned_activity.data["object"]["inReplyToAtomUri"] ==
|
||||||
"https://shitposter.club/notice/2827873"
|
"https://shitposter.club/notice/2827873"
|
||||||
|
|
||||||
assert returned_activity.data["object"]["inReplyToStatusId"] == activity.id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for incoming notices" do
|
test "it works for incoming notices" do
|
||||||
|
|
|
@ -342,7 +342,7 @@ test "replying to a status", %{conn: conn} do
|
||||||
activity = Activity.get_by_id(id)
|
activity = Activity.get_by_id(id)
|
||||||
|
|
||||||
assert activity.data["context"] == replied_to.data["context"]
|
assert activity.data["context"] == replied_to.data["context"]
|
||||||
assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
|
assert Activity.get_in_reply_to_activity(activity).id == replied_to.id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "posting a status with an invalid in_reply_to_id", %{conn: conn} do
|
test "posting a status with an invalid in_reply_to_id", %{conn: conn} do
|
||||||
|
@ -2724,7 +2724,7 @@ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{c
|
||||||
activity = Activity.get_by_id(id)
|
activity = Activity.get_by_id(id)
|
||||||
|
|
||||||
assert activity.data["object"]["inReplyTo"] == replied_to.data["object"]["id"]
|
assert activity.data["object"]["inReplyTo"] == replied_to.data["object"]["id"]
|
||||||
assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
|
assert Activity.get_in_reply_to_activity(activity).id == replied_to.id
|
||||||
|
|
||||||
# Reblog from the third user
|
# Reblog from the third user
|
||||||
conn2 =
|
conn2 =
|
||||||
|
|
|
@ -105,7 +105,7 @@ test "create a status that is a reply" do
|
||||||
get_in(activity.data, ["object", "context"])
|
get_in(activity.data, ["object", "context"])
|
||||||
|
|
||||||
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
|
||||||
assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
|
assert Activity.get_in_reply_to_activity(reply).id == activity.id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Follow another user using user_id" do
|
test "Follow another user using user_id" do
|
||||||
|
|
Loading…
Reference in New Issue