mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-22 14:45:16 +00:00
enforce visibility
This commit is contained in:
parent
fdeef7d4df
commit
23c758bbe7
|
@ -15,13 +15,15 @@ defmodule Mix.Tasks.Pleroma.Search do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
|
||||||
from(a in Activity, where: not ilike(a.actor, "%/relay"))
|
from(a in Activity, where: not ilike(a.actor, "%/relay"))
|
||||||
|
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
|
||||||
|> Activity.with_preloaded_object()
|
|> Activity.with_preloaded_object()
|
||||||
|> Activity.with_preloaded_user_actor()
|
|> Activity.with_preloaded_user_actor()
|
||||||
|> get_all
|
|> get_all
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_all(query, max_id \\ nil) do
|
defp get_all(query, max_id \\ nil) do
|
||||||
params = %{limit: 20}
|
IO.puts(max_id)
|
||||||
|
params = %{limit: 2000}
|
||||||
|
|
||||||
params =
|
params =
|
||||||
if max_id == nil do
|
if max_id == nil do
|
||||||
|
@ -38,6 +40,12 @@ defmodule Mix.Tasks.Pleroma.Search do
|
||||||
:ok
|
:ok
|
||||||
else
|
else
|
||||||
res
|
res
|
||||||
|
|> Enum.filter(fn x ->
|
||||||
|
t = x.object
|
||||||
|
|> Map.get(:data, %{})
|
||||||
|
|> Map.get("type", "")
|
||||||
|
t == "Note"
|
||||||
|
end)
|
||||||
|> Pleroma.Elasticsearch.bulk_post(:activities)
|
|> Pleroma.Elasticsearch.bulk_post(:activities)
|
||||||
|
|
||||||
get_all(query, List.last(res).id)
|
get_all(query, List.last(res).id)
|
||||||
|
|
|
@ -2,6 +2,7 @@ defmodule Pleroma.Search.Elasticsearch do
|
||||||
@behaviour Pleroma.Search
|
@behaviour Pleroma.Search
|
||||||
|
|
||||||
alias Pleroma.Web.MastodonAPI.StatusView
|
alias Pleroma.Web.MastodonAPI.StatusView
|
||||||
|
alias Pleroma.Web.ActivityPub.Visibility
|
||||||
|
|
||||||
defp to_es(term) when is_binary(term) do
|
defp to_es(term) when is_binary(term) do
|
||||||
%{
|
%{
|
||||||
|
@ -62,6 +63,7 @@ defmodule Pleroma.Search.Elasticsearch do
|
||||||
|> Map.get("hits", [])
|
|> Map.get("hits", [])
|
||||||
|> Enum.map(fn result -> result["_id"] end)
|
|> Enum.map(fn result -> result["_id"] end)
|
||||||
|> Pleroma.Activity.all_by_ids_with_object()
|
|> Pleroma.Activity.all_by_ids_with_object()
|
||||||
|
|> Enum.filter(fn x -> Visibility.visible_for_user?(x, user) end)
|
||||||
|
|
||||||
%{
|
%{
|
||||||
"accounts" => [],
|
"accounts" => [],
|
||||||
|
|
Loading…
Reference in a new issue