Commit 8de523c8 authored by lain's avatar lain
Browse files

Basic AP objects.

parent 093fd183
defmodule Pleroma.Activity do
use Ecto.Schema
schema "activities" do
field :data, :map
timestamps()
end
end
defmodule Pleroma.Object do
use Ecto.Schema
schema "objects" do
field :data, :map
timestamps()
end
end
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
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
defmodule Pleroma.Repo.Migrations.CreatePleroma.Object do
use Ecto.Migration
def change do
create table(:objects) do
add :data, :map
timestamps()
end
end
end
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment