Merge branch 'stable' into release/2.0.0
[akkoma] / lib / pleroma / conversation / participation.ex
index aafe572803f0b99f848c146f50a931c39b4eb447..693825cf5fbef554bffda87bc7bb20757afb7e12 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Conversation.Participation do
@@ -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}
@@ -131,10 +133,8 @@ defmodule Pleroma.Conversation.Participation do
       [user.id | user_ids]
       |> Enum.uniq()
       |> Enum.reduce([], fn user_id, acc ->
-        case FlakeId.Ecto.CompatType.dump(user_id) do
-          {:ok, user_id} -> [user_id | acc]
-          _ -> acc
-        end
+        {:ok, user_id} = FlakeId.Ecto.CompatType.dump(user_id)
+        [user_id | acc]
       end)
 
     conversation_subquery =