Keep incoming Link tag
This commit is contained in:
parent
e9cd004ba1
commit
479a6f11db
2 changed files with 20 additions and 1 deletions
|
@ -9,15 +9,20 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
require Pleroma.Constants
|
||||||
|
|
||||||
@primary_key false
|
@primary_key false
|
||||||
embedded_schema do
|
embedded_schema do
|
||||||
# Common
|
# Common
|
||||||
field(:type, :string)
|
field(:type, :string)
|
||||||
field(:name, :string)
|
field(:name, :string)
|
||||||
|
|
||||||
# Mention, Hashtag
|
# Mention, Hashtag, Link
|
||||||
field(:href, ObjectValidators.Uri)
|
field(:href, ObjectValidators.Uri)
|
||||||
|
|
||||||
|
# Link
|
||||||
|
field(:mediaType, :string)
|
||||||
|
|
||||||
# Emoji
|
# Emoji
|
||||||
embeds_one :icon, IconObjectValidator, primary_key: false do
|
embeds_one :icon, IconObjectValidator, primary_key: false do
|
||||||
field(:type, :string)
|
field(:type, :string)
|
||||||
|
@ -68,6 +73,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
|
||||||
|> validate_required([:type, :name, :icon])
|
|> validate_required([:type, :name, :icon])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def changeset(struct, %{"type" => "Link"} = data) do
|
||||||
|
struct
|
||||||
|
|> cast(data, [:type, :name, :mediaType, :href])
|
||||||
|
|> validate_inclusion(:mediaType, Pleroma.Constants.activity_json_mime_types())
|
||||||
|
|> validate_required([:type, :href, :mediaType])
|
||||||
|
end
|
||||||
|
|
||||||
def changeset(struct, %{"type" => _} = data) do
|
def changeset(struct, %{"type" => _} = data) do
|
||||||
struct
|
struct
|
||||||
|> cast(data, [])
|
|> cast(data, [])
|
||||||
|
|
|
@ -157,5 +157,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
||||||
|
|
||||||
assert cng.valid?
|
assert cng.valid?
|
||||||
assert cng.changes.quoteUrl == "https://server.example/objects/123"
|
assert cng.changes.quoteUrl == "https://server.example/objects/123"
|
||||||
|
|
||||||
|
assert Enum.at(cng.changes.tag, 0).changes == %{
|
||||||
|
type: "Link",
|
||||||
|
mediaType: "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"",
|
||||||
|
href: "https://server.example/objects/123",
|
||||||
|
name: "RE: https://server.example/objects/123"
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue