mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 11:19:19 +00:00
Fix specs, add local marker to actitivies.
This commit is contained in:
parent
89c1e90eb2
commit
56bacc90d1
4 changed files with 15 additions and 2 deletions
|
@ -5,6 +5,7 @@ defmodule Pleroma.Activity do
|
||||||
|
|
||||||
schema "activities" do
|
schema "activities" do
|
||||||
field :data, :map
|
field :data, :map
|
||||||
|
field :local, :boolean, default: true
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.AddLocalFieldToActivities do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:activities) do
|
||||||
|
add :local, :boolean, default: true
|
||||||
|
end
|
||||||
|
|
||||||
|
create index(:activities, [:local])
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,7 +5,7 @@ defmodule Pleroma.Builders.ActivityBuilder do
|
||||||
def build(data \\ %{}, opts \\ %{}) do
|
def build(data \\ %{}, opts \\ %{}) do
|
||||||
user = opts[:user] || Pleroma.Factory.insert(:user)
|
user = opts[:user] || Pleroma.Factory.insert(:user)
|
||||||
activity = %{
|
activity = %{
|
||||||
"id" => 1,
|
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id,
|
||||||
"actor" => user.ap_id,
|
"actor" => user.ap_id,
|
||||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"object" => %{
|
"object" => %{
|
||||||
|
@ -23,7 +23,7 @@ defmodule Pleroma.Builders.ActivityBuilder do
|
||||||
|
|
||||||
def insert_list(times, data \\ %{}, opts \\ %{}) do
|
def insert_list(times, data \\ %{}, opts \\ %{}) do
|
||||||
Enum.map(1..times, fn (n) ->
|
Enum.map(1..times, fn (n) ->
|
||||||
{:ok, activity} = insert(Map.merge(data, %{"id" => n}))
|
{:ok, activity} = insert(data)
|
||||||
activity
|
activity
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
||||||
assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user))
|
assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user))
|
||||||
assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
|
assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public")
|
||||||
assert Enum.member?(get_in(activity.data, ["to"]), "shp")
|
assert Enum.member?(get_in(activity.data, ["to"]), "shp")
|
||||||
|
assert activity.local == true
|
||||||
|
|
||||||
# Add a context
|
# Add a context
|
||||||
assert is_binary(get_in(activity.data, ["context"]))
|
assert is_binary(get_in(activity.data, ["context"]))
|
||||||
|
|
Loading…
Reference in a new issue