forked from AkkomaGang/akkoma
Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma into develop
This commit is contained in:
commit
b76001ded3
4 changed files with 25 additions and 5 deletions
|
@ -12,16 +12,17 @@ defmodule Pleroma.Activity do
|
||||||
|
|
||||||
def get_by_ap_id(ap_id) do
|
def get_by_ap_id(ap_id) do
|
||||||
Repo.one(from activity in Activity,
|
Repo.one(from activity in Activity,
|
||||||
where: fragment("? @> ?", activity.data, ^%{id: ap_id}))
|
where: fragment("(?)->>'id' = ?", activity.data, ^to_string(ap_id)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_by_object_ap_id(ap_id) do
|
def all_by_object_ap_id(ap_id) do
|
||||||
Repo.all(from activity in Activity,
|
Repo.all(from activity in Activity,
|
||||||
where: fragment("? @> ?", activity.data, ^%{object: %{id: ap_id}}))
|
where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_create_activity_by_object_ap_id(ap_id) do
|
def get_create_activity_by_object_ap_id(ap_id) do
|
||||||
Repo.one(from activity in Activity,
|
Repo.one(from activity in Activity,
|
||||||
where: fragment("? @> ?", activity.data, ^%{type: "Create", object: %{id: ap_id}}))
|
where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id))
|
||||||
|
and fragment("(?)->>'type' = 'Create'", activity.data))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,10 +53,14 @@ def publish(topic, user, activity) do
|
||||||
Logger.debug(fn -> "Pushing to #{sub.callback}" end)
|
Logger.debug(fn -> "Pushing to #{sub.callback}" end)
|
||||||
|
|
||||||
Task.start(fn ->
|
Task.start(fn ->
|
||||||
@httpoison.post(sub.callback, response, [
|
with {:ok, %{status_code: code}} <- @httpoison.post(sub.callback, response, [
|
||||||
{"Content-Type", "application/atom+xml"},
|
{"Content-Type", "application/atom+xml"},
|
||||||
{"X-Hub-Signature", "sha1=#{signature}"}
|
{"X-Hub-Signature", "sha1=#{signature}"}
|
||||||
])
|
]) do
|
||||||
|
Logger.debug(fn -> "Pushed to #{sub.callback}, code #{code}" end)
|
||||||
|
else e ->
|
||||||
|
Logger.debug(fn -> "Couldn't push to #{sub.callback}, #{inspect(e)}" end)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.AddObjectActivityIndex do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index)
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.AddObjectActivityIndexPartTwo do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
drop index(:objects, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index)
|
||||||
|
create index(:activities, ["(data->'object'->>'id')", "(data->>'type')"], name: :activities_create_objects_index)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue