Keep incoming Link tag
This commit is contained in:
parent
e9cd004ba1
commit
479a6f11db
|
@ -9,15 +9,20 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
|
|||
|
||||
import Ecto.Changeset
|
||||
|
||||
require Pleroma.Constants
|
||||
|
||||
@primary_key false
|
||||
embedded_schema do
|
||||
# Common
|
||||
field(:type, :string)
|
||||
field(:name, :string)
|
||||
|
||||
# Mention, Hashtag
|
||||
# Mention, Hashtag, Link
|
||||
field(:href, ObjectValidators.Uri)
|
||||
|
||||
# Link
|
||||
field(:mediaType, :string)
|
||||
|
||||
# Emoji
|
||||
embeds_one :icon, IconObjectValidator, primary_key: false do
|
||||
field(:type, :string)
|
||||
|
@ -68,6 +73,13 @@ def changeset(struct, %{"type" => "Emoji"} = data) do
|
|||
|> validate_required([:type, :name, :icon])
|
||||
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
|
||||
struct
|
||||
|> cast(data, [])
|
||||
|
|
|
@ -157,5 +157,12 @@ test "Parse tag as quote" do
|
|||
|
||||
assert cng.valid?
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue