Merge branch 'updated-at-on-conversation-read' into 'develop'

MastodonAPI: Fix mark-as-read bringing the conversation to the top (`POST /api/v1/conversations/:id/read`)

See merge request pleroma/pleroma!2080
This commit is contained in:
feld 2020-01-12 18:37:52 +00:00
commit 8b4d81609d
3 changed files with 10 additions and 6 deletions

View file

@ -105,6 +105,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` - 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) - 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 - 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`) now no longer brings it to the top in the user's direct conversation list
</details> </details>
## [1.1.6] - 2019-11-19 ## [1.1.6] - 2019-11-19

View file

@ -64,11 +64,13 @@ def mark_as_read(%User{} = user, %Conversation{} = conversation) do
end end
def mark_as_read(participation) do def mark_as_read(participation) do
participation __MODULE__
|> read_cng(%{read: true}) |> where(id: ^participation.id)
|> Repo.update() |> update(set: [read: true])
|> select([p], p)
|> Repo.update_all([])
|> case do |> case do
{:ok, participation} -> {1, [participation]} ->
participation = Repo.preload(participation, :user) participation = Repo.preload(participation, :user)
User.set_unread_conversation_count(participation.user) User.set_unread_conversation_count(participation.user)
{:ok, participation} {:ok, participation}

View file

@ -125,9 +125,10 @@ test "recreating an existing participations sets it to unread" do
test "it marks a participation as read" do test "it marks a participation as read" do
participation = insert(:participation, %{read: false}) 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 end
test "it marks a participation as unread" do test "it marks a participation as unread" do