X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fconversation%2Fparticipation.ex;h=8bc3e85d6e1f50f65c199c52999e05e903508fcf;hb=d833d2c1fd3861caa055c2d5c87d549b8f246d30;hp=e5d28ebffdfc786480fc417ff409d116044f76bd;hpb=70c7a26de8135ddc089fc0d2e0766e2e793d505c;p=akkoma
diff --git a/lib/pleroma/conversation/participation.ex b/lib/pleroma/conversation/participation.ex
index e5d28ebff..8bc3e85d6 100644
--- a/lib/pleroma/conversation/participation.ex
+++ b/lib/pleroma/conversation/participation.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Conversation.Participation do
@@ -128,24 +128,19 @@ defmodule Pleroma.Conversation.Participation do
|> Pleroma.Pagination.fetch_paginated(params)
end
- def restrict_recipients(query, user, %{"recipients" => user_ids}) do
- user_ids =
+ def restrict_recipients(query, user, %{recipients: user_ids}) do
+ user_binary_ids =
[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
- end)
+ |> User.binary_id()
conversation_subquery =
__MODULE__
|> group_by([p], p.conversation_id)
|> having(
[p],
- count(p.user_id) == ^length(user_ids) and
- fragment("array_agg(?) @> ?", p.user_id, ^user_ids)
+ count(p.user_id) == ^length(user_binary_ids) and
+ fragment("array_agg(?) @> ?", p.user_id, ^user_binary_ids)
)
|> select([p], %{id: p.conversation_id})
@@ -167,17 +162,20 @@ defmodule Pleroma.Conversation.Participation do
for_user(user, params)
|> Enum.map(fn participation ->
activity_id =
- ActivityPub.fetch_latest_activity_id_for_context(participation.conversation.ap_id, %{
- "user" => user,
- "blocking_user" => user
- })
+ ActivityPub.fetch_latest_direct_activity_id_for_context(
+ participation.conversation.ap_id,
+ %{
+ user: user,
+ blocking_user: user
+ }
+ )
%{
participation
| last_activity_id: activity_id
}
end)
- |> Enum.filter(& &1.last_activity_id)
+ |> Enum.reject(&is_nil(&1.last_activity_id))
end
def get(_, _ \\ [])