Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/lib/pleroma/web/activity_pub/object_validators/place_validator.ex b/lib/pleroma/web/activity_pub/object_validators/place_validator.ex
index 7c3ebdca1..afc756897 100644
--- a/lib/pleroma/web/activity_pub/object_validators/place_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/place_validator.ex
@@ -1,71 +1,71 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.PlaceValidator do
use Ecto.Schema
import Ecto.Changeset
@primary_key false
embedded_schema do
field(:type, :string)
field(:name, :string)
field(:longitude, :float)
field(:latitude, :float)
field(:accuracy, :float)
field(:altitude, :float)
field(:radius, :float)
field(:units, :string)
embeds_one :address, Address do
field(:type, :string)
field(:postalCode, :string)
field(:addressRegion, :string)
field(:streetAddress, :string)
field(:addressCountry, :string)
field(:addressLocality, :string)
end
end
def changeset(struct, data) do
data = fix(data)
struct
|> cast(data, [:type, :name, :longitude, :latitude, :accuracy, :altitude, :radius, :units])
|> cast_embed(:address, with: &address_changeset/2)
|> validate_inclusion(:type, ["Place"])
- |> validate_inclusion(:radius, ~w[cm feet inches km m miles])
+ |> validate_inclusion(:units, ~w[cm feet inches km m miles])
|> validate_number(:accuracy, greater_than_or_equal_to: 0, less_than_or_equal_to: 100)
|> validate_number(:radius, greater_than_or_equal_to: 0)
|> validate_required([:type, :name])
end
def address_changeset(struct, data) do
struct
|> cast(data, [
:type,
:postalCode,
:addressRegion,
:streetAddress,
:addressCountry,
:addressLocality
])
|> validate_inclusion(:type, ["PostalAddress"])
end
defp fix(data) do
data
|> fix_address()
end
defp fix_address(%{"address" => address} = data) when is_binary(address) do
data
|> Map.put("address", %{
"type" => "PostalAddress",
"streetAddress" => address
})
end
defp fix_address(data), do: data
end

File Metadata

Mime Type
text/x-diff
Expires
Sat, Aug 8, 2:45 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1723616
Default Alt Text
(2 KB)

Event Timeline