Fix participation requests query

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-09-25 22:01:34 +02:00
parent 5039c5ca80
commit ba9fe4c6f2
2 changed files with 13 additions and 4 deletions

View file

@ -1246,6 +1246,12 @@ defp restrict_filtered(query, %{blocking_user: %User{} = user}) do
defp restrict_filtered(query, _), do: query
defp restrict_object(query, %{object: object}) do
from(activity in query, where: fragment("?->>'object' = ?", activity.data, ^object))
end
defp restrict_object(query, _), do: query
defp restrict_quote_url(query, %{quote_url: quote_url}) do
from([_activity, object] in query,
where: fragment("(?)->'quoteUrl' = ?", object.data, ^quote_url)
@ -1417,6 +1423,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do
|> restrict_instance(opts)
|> restrict_announce_object_actor(opts)
|> restrict_filtered(opts)
|> restrict_object(opts)
|> restrict_quote_url(opts)
|> Activity.restrict_deactivated_users()
|> exclude_poll_votes(opts)

View file

@ -129,10 +129,12 @@ def participation_requests(
case activity do
%Activity{actor: ^user_ap_id, data: %{"object" => ap_id}} ->
params =
params
|> Map.put(:type, "Join")
|> Map.put(:object, ap_id)
|> Map.put(:state, "pending")
Map.merge(params, %{
type: "Join",
object: ap_id,
state: "pending",
skip_preload: true
})
activities =
[]