forked from mirrors/akkoma
Merge branch '1866-last-status-stuff' into 'develop'
Resolve "/api/v1/conversations returns the wrong `last_status`" Closes #1866 See merge request pleroma/pleroma!2647
This commit is contained in:
commit
b536e57124
5 changed files with 29 additions and 12 deletions
|
@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- In Conversations, return only direct messages as `last_status`
|
||||||
- MFR policy to set global expiration for all local Create activities
|
- MFR policy to set global expiration for all local Create activities
|
||||||
- OGP rich media parser merged with TwitterCard
|
- OGP rich media parser merged with TwitterCard
|
||||||
<details>
|
<details>
|
||||||
|
|
|
@ -162,10 +162,13 @@ defmodule Pleroma.Conversation.Participation do
|
||||||
for_user(user, params)
|
for_user(user, params)
|
||||||
|> Enum.map(fn participation ->
|
|> Enum.map(fn participation ->
|
||||||
activity_id =
|
activity_id =
|
||||||
ActivityPub.fetch_latest_activity_id_for_context(participation.conversation.ap_id, %{
|
ActivityPub.fetch_latest_direct_activity_id_for_context(
|
||||||
user: user,
|
participation.conversation.ap_id,
|
||||||
blocking_user: user
|
%{
|
||||||
})
|
user: user,
|
||||||
|
blocking_user: user
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
%{
|
%{
|
||||||
participation
|
participation
|
||||||
|
|
|
@ -210,7 +210,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
conversation = Repo.preload(conversation, :participations)
|
conversation = Repo.preload(conversation, :participations)
|
||||||
|
|
||||||
last_activity_id =
|
last_activity_id =
|
||||||
fetch_latest_activity_id_for_context(conversation.ap_id, %{
|
fetch_latest_direct_activity_id_for_context(conversation.ap_id, %{
|
||||||
user: user,
|
user: user,
|
||||||
blocking_user: user
|
blocking_user: user
|
||||||
})
|
})
|
||||||
|
@ -517,11 +517,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec fetch_latest_activity_id_for_context(String.t(), keyword() | map()) ::
|
@spec fetch_latest_direct_activity_id_for_context(String.t(), keyword() | map()) ::
|
||||||
FlakeId.Ecto.CompatType.t() | nil
|
FlakeId.Ecto.CompatType.t() | nil
|
||||||
def fetch_latest_activity_id_for_context(context, opts \\ %{}) do
|
def fetch_latest_direct_activity_id_for_context(context, opts \\ %{}) do
|
||||||
context
|
context
|
||||||
|> fetch_activities_for_context_query(Map.merge(%{skip_preload: true}, opts))
|
|> fetch_activities_for_context_query(Map.merge(%{skip_preload: true}, opts))
|
||||||
|
|> restrict_visibility(%{visibility: "direct"})
|
||||||
|> limit(1)
|
|> limit(1)
|
||||||
|> select([a], a.id)
|
|> select([a], a.id)
|
||||||
|> Repo.one()
|
|> Repo.one()
|
||||||
|
|
|
@ -23,10 +23,13 @@ defmodule Pleroma.Web.MastodonAPI.ConversationView do
|
||||||
|
|
||||||
last_activity_id =
|
last_activity_id =
|
||||||
with nil <- participation.last_activity_id do
|
with nil <- participation.last_activity_id do
|
||||||
ActivityPub.fetch_latest_activity_id_for_context(participation.conversation.ap_id, %{
|
ActivityPub.fetch_latest_direct_activity_id_for_context(
|
||||||
user: user,
|
participation.conversation.ap_id,
|
||||||
blocking_user: user
|
%{
|
||||||
})
|
user: user,
|
||||||
|
blocking_user: user
|
||||||
|
}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
activity = Activity.get_by_id_with_object(last_activity_id)
|
activity = Activity.get_by_id_with_object(last_activity_id)
|
||||||
|
|
|
@ -15,8 +15,17 @@ defmodule Pleroma.Web.MastodonAPI.ConversationViewTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, parent} = CommonAPI.post(user, %{status: "parent"})
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
CommonAPI.post(user, %{status: "hey @#{other_user.nickname}", visibility: "direct"})
|
CommonAPI.post(user, %{
|
||||||
|
status: "hey @#{other_user.nickname}",
|
||||||
|
visibility: "direct",
|
||||||
|
in_reply_to_id: parent.id
|
||||||
|
})
|
||||||
|
|
||||||
|
{:ok, _reply_activity} =
|
||||||
|
CommonAPI.post(user, %{status: "hu", visibility: "public", in_reply_to_id: parent.id})
|
||||||
|
|
||||||
[participation] = Participation.for_user_with_last_activity_id(user)
|
[participation] = Participation.for_user_with_last_activity_id(user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue