mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-22 14:45:16 +00:00
merge
This commit is contained in:
parent
cc4c5f22f4
commit
9d5d964bf8
|
@ -4,7 +4,6 @@
|
|||
|
||||
defmodule Mix.Tasks.Pleroma.Activity do
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Activity.Search
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Pagination
|
||||
|
|
|
@ -24,8 +24,8 @@ defmodule Mix.Tasks.Pleroma.Search do
|
|||
end
|
||||
|
||||
def run(["import", "users" | _rest]) do
|
||||
start_pleroma()
|
||||
|
||||
start_pleroma()
|
||||
|
||||
from(u in User, where: u.nickname not in ["internal.fetch", "relay"])
|
||||
|> get_all(:users)
|
||||
end
|
||||
|
|
|
@ -46,26 +46,31 @@ defmodule Pleroma.Elasticsearch do
|
|||
end
|
||||
|
||||
def put(%Activity{} = activity) do
|
||||
{:ok, _} = Elastix.Document.index(
|
||||
url(),
|
||||
"activities",
|
||||
"activity",
|
||||
DocumentMappings.Activity.id(activity),
|
||||
DocumentMappings.Activity.encode(activity)
|
||||
)
|
||||
{:ok, _} = bulk_post(
|
||||
activity.object.hashtags, :hashtags
|
||||
)
|
||||
{:ok, _} =
|
||||
Elastix.Document.index(
|
||||
url(),
|
||||
"activities",
|
||||
"activity",
|
||||
DocumentMappings.Activity.id(activity),
|
||||
DocumentMappings.Activity.encode(activity)
|
||||
)
|
||||
|
||||
{:ok, _} =
|
||||
bulk_post(
|
||||
activity.object.hashtags,
|
||||
:hashtags
|
||||
)
|
||||
end
|
||||
|
||||
def put(%User{} = user) do
|
||||
{:ok, _ } = Elastix.Document.index(
|
||||
url(),
|
||||
"users",
|
||||
"user",
|
||||
DocumentMappings.User.id(user),
|
||||
DocumentMappings.User.encode(user)
|
||||
)
|
||||
{:ok, _} =
|
||||
Elastix.Document.index(
|
||||
url(),
|
||||
"users",
|
||||
"user",
|
||||
DocumentMappings.User.id(user),
|
||||
DocumentMappings.User.encode(user)
|
||||
)
|
||||
end
|
||||
|
||||
def bulk_post(data, :activities) do
|
||||
|
@ -87,12 +92,13 @@ defmodule Pleroma.Elasticsearch do
|
|||
end)
|
||||
|> List.flatten()
|
||||
|
||||
{:ok, %{body: %{"errors" => false}}} = Elastix.Bulk.post(
|
||||
url(),
|
||||
d,
|
||||
index: "activities",
|
||||
type: "activity"
|
||||
)
|
||||
{:ok, %{body: %{"errors" => false}}} =
|
||||
Elastix.Bulk.post(
|
||||
url(),
|
||||
d,
|
||||
index: "activities",
|
||||
type: "activity"
|
||||
)
|
||||
end
|
||||
|
||||
def bulk_post(data, :users) do
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule Pleroma.Search.Elasticsearch.Parsers.Hashtag do
|
|||
%{
|
||||
term: %{
|
||||
hashtag: %{
|
||||
value: String.downcase(term),
|
||||
value: String.downcase(term)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.Search.Elasticsearch.Parsers.User do
|
|||
query: term,
|
||||
operator: "AND"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue