TagValidator: Drop unrecognized tags
This commit is contained in:
parent
45646ff52c
commit
5cfb0578a6
3 changed files with 12 additions and 6 deletions
|
@ -68,8 +68,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
|
||||||
|> validate_required([:type, :name, :icon])
|
|> validate_required([:type, :name, :icon])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fallback
|
def changeset(struct, %{"type" => _} = data) do
|
||||||
def changeset(struct, data), do: cast(struct, data, [:type, :name])
|
struct
|
||||||
|
|> cast(data, [])
|
||||||
|
|> Map.put(:action, :ignore)
|
||||||
|
end
|
||||||
|
|
||||||
def icon_changeset(struct, data) do
|
def icon_changeset(struct, data) do
|
||||||
struct
|
struct
|
||||||
|
|
5
test/fixtures/fep-e232.json
vendored
5
test/fixtures/fep-e232.json
vendored
|
@ -9,6 +9,11 @@
|
||||||
"content": "<p>test <a href=\"https://example.org/objects/9\">https://example.org/objects/9</a></p>",
|
"content": "<p>test <a href=\"https://example.org/objects/9\">https://example.org/objects/9</a></p>",
|
||||||
"published": "2022-10-01T21:30:05.211215Z",
|
"published": "2022-10-01T21:30:05.211215Z",
|
||||||
"tag": [
|
"tag": [
|
||||||
|
{
|
||||||
|
"name": "@bob@example.net",
|
||||||
|
"type": "Mention",
|
||||||
|
"href": "https://example.net/users/bob"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "https://example.org/objects/9",
|
"name": "https://example.org/objects/9",
|
||||||
"type": "Link",
|
"type": "Link",
|
||||||
|
|
|
@ -124,8 +124,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
assert activity.data["context"] == object.data["context"]
|
assert activity.data["context"] == object.data["context"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-e232.md
|
test "it drops link tags" do
|
||||||
test "it accepts FEP-e232 link tags" do
|
|
||||||
insert(:user, ap_id: "https://example.org/users/alice")
|
insert(:user, ap_id: "https://example.org/users/alice")
|
||||||
|
|
||||||
message = File.read!("test/fixtures/fep-e232.json") |> Jason.decode!()
|
message = File.read!("test/fixtures/fep-e232.json") |> Jason.decode!()
|
||||||
|
@ -136,8 +135,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
assert length(object.data["tag"]) == 1
|
assert length(object.data["tag"]) == 1
|
||||||
|
|
||||||
tag = object.data["tag"] |> List.first()
|
tag = object.data["tag"] |> List.first()
|
||||||
assert tag["type"] == "Link"
|
assert tag["type"] == "Mention"
|
||||||
assert tag["name"] == "https://example.org/objects/9"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue