Merge branch 'accept-tags-2.5' into 'develop'
TagValidator: Drop unrecognized Tag types Closes #2952 See merge request pleroma/pleroma!3823
This commit is contained in:
commit
0524e66a05
@ -68,6 +68,12 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidator do
|
|||||||
|> validate_required([:type, :name, :icon])
|
|> validate_required([:type, :name, :icon])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def changeset(struct, %{"type" => _} = data) do
|
||||||
|
struct
|
||||||
|
|> cast(data, [])
|
||||||
|
|> Map.put(:action, :ignore)
|
||||||
|
end
|
||||||
|
|
||||||
def icon_changeset(struct, data) do
|
def icon_changeset(struct, data) do
|
||||||
struct
|
struct
|
||||||
|> cast(data, [:type, :url])
|
|> cast(data, [:type, :url])
|
||||||
|
31
test/fixtures/fep-e232.json
vendored
Normal file
31
test/fixtures/fep-e232.json
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"type": "Create",
|
||||||
|
"actor": "https://example.org/users/alice",
|
||||||
|
"object": {
|
||||||
|
"id": "https://example.org/objects/10",
|
||||||
|
"type": "Note",
|
||||||
|
"attributedTo": "https://example.org/users/alice",
|
||||||
|
"content": "<p>test <a href=\"https://example.org/objects/9\">https://example.org/objects/9</a></p>",
|
||||||
|
"published": "2022-10-01T21:30:05.211215Z",
|
||||||
|
"tag": [
|
||||||
|
{
|
||||||
|
"name": "@bob@example.net",
|
||||||
|
"type": "Mention",
|
||||||
|
"href": "https://example.net/users/bob"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "https://example.org/objects/9",
|
||||||
|
"type": "Link",
|
||||||
|
"href": "https://example.org/objects/9",
|
||||||
|
"mediaType": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://example.org/users/alice/followers"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -123,6 +123,20 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||||||
|
|
||||||
assert activity.data["context"] == object.data["context"]
|
assert activity.data["context"] == object.data["context"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it drops link tags" do
|
||||||
|
insert(:user, ap_id: "https://example.org/users/alice")
|
||||||
|
|
||||||
|
message = File.read!("test/fixtures/fep-e232.json") |> Jason.decode!()
|
||||||
|
|
||||||
|
assert {:ok, activity} = Transmogrifier.handle_incoming(message)
|
||||||
|
|
||||||
|
object = Object.normalize(activity)
|
||||||
|
assert length(object.data["tag"]) == 1
|
||||||
|
|
||||||
|
tag = object.data["tag"] |> List.first()
|
||||||
|
assert tag["type"] == "Mention"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "prepare outgoing" do
|
describe "prepare outgoing" do
|
||||||
|
Loading…
Reference in New Issue
Block a user