diff options
author | feld <feld@feld.me> | 2020-01-12 18:37:52 +0000 |
---|---|---|
committer | feld <feld@feld.me> | 2020-01-12 18:37:52 +0000 |
commit | 8b4d81609d5627d62b826bcd3e87290cb513495f (patch) | |
tree | 009ced1c40a279b1decddd06c8af7bcfe53c1e8d | |
parent | 6cc5341d26426f98a53a6e46787f1457f974f321 (diff) | |
parent | 180f257ced4ace9467d1946a582a5f6f962d0163 (diff) | |
download | pleroma-8b4d81609d5627d62b826bcd3e87290cb513495f.tar.gz pleroma-8b4d81609d5627d62b826bcd3e87290cb513495f.zip |
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
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/pleroma/conversation/participation.ex | 10 | ||||
-rw-r--r-- | test/conversation/participation_test.exs | 5 |
3 files changed, 10 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 04efc97c0..0907fbd53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` - 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`) now no longer brings it to the top in the user's direct conversation list </details> ## [1.1.6] - 2019-11-19 diff --git a/lib/pleroma/conversation/participation.ex b/lib/pleroma/conversation/participation.ex index aafe57280..e5d28ebff 100644 --- a/lib/pleroma/conversation/participation.ex +++ b/lib/pleroma/conversation/participation.ex @@ -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} diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs index ba81c0d4b..ab9f27b2f 100644 --- a/test/conversation/participation_test.exs +++ b/test/conversation/participation_test.exs @@ -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 |