forked from AkkomaGang/akkoma
merge
This commit is contained in:
parent
cc4c5f22f4
commit
9d5d964bf8
5 changed files with 33 additions and 28 deletions
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
defmodule Mix.Tasks.Pleroma.Activity do
|
defmodule Mix.Tasks.Pleroma.Activity do
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.Activity.Search
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Pagination
|
alias Pleroma.Pagination
|
||||||
|
|
|
@ -46,26 +46,31 @@ def maybe_put_into_elasticsearch(_) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def put(%Activity{} = activity) do
|
def put(%Activity{} = activity) do
|
||||||
{:ok, _} = Elastix.Document.index(
|
{:ok, _} =
|
||||||
url(),
|
Elastix.Document.index(
|
||||||
"activities",
|
url(),
|
||||||
"activity",
|
"activities",
|
||||||
DocumentMappings.Activity.id(activity),
|
"activity",
|
||||||
DocumentMappings.Activity.encode(activity)
|
DocumentMappings.Activity.id(activity),
|
||||||
)
|
DocumentMappings.Activity.encode(activity)
|
||||||
{:ok, _} = bulk_post(
|
)
|
||||||
activity.object.hashtags, :hashtags
|
|
||||||
)
|
{:ok, _} =
|
||||||
|
bulk_post(
|
||||||
|
activity.object.hashtags,
|
||||||
|
:hashtags
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def put(%User{} = user) do
|
def put(%User{} = user) do
|
||||||
{:ok, _ } = Elastix.Document.index(
|
{:ok, _} =
|
||||||
url(),
|
Elastix.Document.index(
|
||||||
"users",
|
url(),
|
||||||
"user",
|
"users",
|
||||||
DocumentMappings.User.id(user),
|
"user",
|
||||||
DocumentMappings.User.encode(user)
|
DocumentMappings.User.id(user),
|
||||||
)
|
DocumentMappings.User.encode(user)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_post(data, :activities) do
|
def bulk_post(data, :activities) do
|
||||||
|
@ -87,12 +92,13 @@ def bulk_post(data, :activities) do
|
||||||
end)
|
end)
|
||||||
|> List.flatten()
|
|> List.flatten()
|
||||||
|
|
||||||
{:ok, %{body: %{"errors" => false}}} = Elastix.Bulk.post(
|
{:ok, %{body: %{"errors" => false}}} =
|
||||||
url(),
|
Elastix.Bulk.post(
|
||||||
d,
|
url(),
|
||||||
index: "activities",
|
d,
|
||||||
type: "activity"
|
index: "activities",
|
||||||
)
|
type: "activity"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_post(data, :users) do
|
def bulk_post(data, :users) do
|
||||||
|
|
|
@ -3,7 +3,7 @@ defp to_es(term) when is_binary(term) do
|
||||||
%{
|
%{
|
||||||
term: %{
|
term: %{
|
||||||
hashtag: %{
|
hashtag: %{
|
||||||
value: String.downcase(term),
|
value: String.downcase(term)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue