--- /dev/null
+defmodule Pleroma.Activity do
+ use Ecto.Schema
+
+ schema "activities" do
+ field :data, :map
+
+ timestamps()
+ end
+end
--- /dev/null
+defmodule Pleroma.Object do
+ use Ecto.Schema
+
+ schema "objects" do
+ field :data, :map
+
+ timestamps()
+ end
+end
--- /dev/null
+defmodule Pleroma.Web.ActivityPub.ActivityPub do
+ alias Pleroma.Repo
+ alias Pleroma.Activity
+
+ def insert(map) when is_map(map) do
+ Repo.insert(%Activity{data: map})
+ end
+end
--- /dev/null
+defmodule Pleroma.Repo.Migrations.CreatePleroma.Activity do
+ use Ecto.Migration
+
+ def change do
+ create table(:activities) do
+ add :data, :map
+
+ timestamps()
+ end
+
+ create index(:activities, [:data], using: :gin)
+
+ end
+end
--- /dev/null
+defmodule Pleroma.Repo.Migrations.CreatePleroma.Object do
+ use Ecto.Migration
+
+ def change do
+ create table(:objects) do
+ add :data, :map
+
+ timestamps()
+ end
+
+ end
+end
--- /dev/null
+defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
+ use Pleroma.DataCase
+ alias Pleroma.Web.ActivityPub.ActivityPub
+ alias Pleroma.Activity
+
+ describe "insertion" do
+ test "inserts a given map into the activity database" do
+ data = %{
+ ok: true
+ }
+
+ {:ok, %Activity{} = activity} = ActivityPub.insert(data)
+ assert activity.data == data
+ end
+ end
+
+end