mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-22 14:45:16 +00:00
Fix mark-as-read (POST /api/v1/conversations/:id/read
) refreshing updated_at and bringing conversation to the top in the user's direct conversation list
This commit is contained in:
parent
ee0c40831e
commit
0b6d1292d2
|
@ -104,6 +104,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Mastodon API: Inability to get some local users by nickname in `/api/v1/accounts/:id_or_nickname`
|
||||
- AdminAPI: If some status received reports both in the "new" format and "old" format it was considered reports on two different statuses (in the context of grouped reports)
|
||||
- Admin API: Error when trying to update reports in the "old" format
|
||||
- Mastodon API: Marking a conversation as read (`POST /api/v1/conversations/:id/read`) brings it to the top in the user's direct conversation list
|
||||
</details>
|
||||
|
||||
## [1.1.6] - 2019-11-19
|
||||
|
|
|
@ -64,11 +64,13 @@ defmodule Pleroma.Conversation.Participation do
|
|||
end
|
||||
|
||||
def mark_as_read(participation) do
|
||||
participation
|
||||
|> read_cng(%{read: true})
|
||||
|> Repo.update()
|
||||
__MODULE__
|
||||
|> where(id: ^participation.id)
|
||||
|> update(set: [read: true])
|
||||
|> select([p], p)
|
||||
|> Repo.update_all([])
|
||||
|> case do
|
||||
{:ok, participation} ->
|
||||
{1, [participation]} ->
|
||||
participation = Repo.preload(participation, :user)
|
||||
User.set_unread_conversation_count(participation.user)
|
||||
{:ok, participation}
|
||||
|
|
|
@ -125,9 +125,10 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
test "it marks a participation as read" do
|
||||
participation = insert(:participation, %{read: false})
|
||||
{:ok, participation} = Participation.mark_as_read(participation)
|
||||
{:ok, updated_participation} = Participation.mark_as_read(participation)
|
||||
|
||||
assert participation.read
|
||||
assert updated_participation.read
|
||||
assert updated_participation.updated_at == participation.updated_at
|
||||
end
|
||||
|
||||
test "it marks a participation as unread" do
|
||||
|
|
Loading…
Reference in a new issue