CommonFields: Use BareUri for :url
Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/3121
This commit is contained in:
parent
fb3335ffe2
commit
a5066bb078
|
@ -0,0 +1 @@
|
||||||
|
Allow non-HTTP(s) URIs in "url" fields for compatibility with "FEP-fffd: Proxy Objects"
|
|
@ -58,7 +58,7 @@ defmacro status_object_fields do
|
||||||
field(:like_count, :integer, default: 0)
|
field(:like_count, :integer, default: 0)
|
||||||
field(:announcement_count, :integer, default: 0)
|
field(:announcement_count, :integer, default: 0)
|
||||||
field(:inReplyTo, ObjectValidators.ObjectID)
|
field(:inReplyTo, ObjectValidators.ObjectID)
|
||||||
field(:url, ObjectValidators.Uri)
|
field(:url, ObjectValidators.BareUri)
|
||||||
|
|
||||||
field(:likes, {:array, ObjectValidators.ObjectID}, default: [])
|
field(:likes, {:array, ObjectValidators.ObjectID}, default: [])
|
||||||
field(:announcements, {:array, ObjectValidators.ObjectID}, default: [])
|
field(:announcements, {:array, ObjectValidators.ObjectID}, default: [])
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.BareUriTest do
|
||||||
|
use Pleroma.DataCase, async: true
|
||||||
|
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators.BareUri
|
||||||
|
|
||||||
|
test "diaspora://" do
|
||||||
|
text = "diaspora://alice@fediverse.example/post/deadbeefdeadbeefdeadbeefdeadbeef"
|
||||||
|
assert {:ok, text} = BareUri.cast(text)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "nostr:" do
|
||||||
|
text = "nostr:note1gwdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
|
||||||
|
assert {:ok, text} = BareUri.cast(text)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "errors for non-URIs" do
|
||||||
|
assert :error == SafeText.cast(1)
|
||||||
|
assert :error == SafeText.cast("foo")
|
||||||
|
assert :error == SafeText.cast("foo bar")
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue