diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-03-30 18:07:01 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-03-30 18:07:29 +0200 |
commit | 6aa1523bb3d8dfe12ce5143d27023fd833b0c1aa (patch) | |
tree | 94b67050b13883c19fad0ef1bf52f5a5d0ddf8c9 /lib | |
parent | 40eb0e4c24b74e608f11f9f77d9ef2d843641014 (diff) | |
download | pleroma-6aa1523bb3d8dfe12ce5143d27023fd833b0c1aa.tar.gz |
Put objects in inserted activties into the db.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/object.ex | 7 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index a31f40d07..f932034d7 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -1,9 +1,16 @@ defmodule Pleroma.Object do use Ecto.Schema + alias Pleroma.{Repo, Object} + import Ecto.Query schema "objects" do field :data, :map timestamps() end + + def get_by_ap_id(ap_id) do + Repo.one(from object in Object, + where: fragment("? @> ?", object.data, ^%{id: ap_id})) + end end diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 6c8250de8..b01def693 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -8,6 +8,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do map = if map["object"] do object = Map.put_new_lazy(map["object"], "id", &generate_object_id/0) + Repo.insert!(%Object{data: object}) Map.put(map, "object", object) else map |