mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-25 07:36:07 +00:00
[#3213] Ignoring of blank elements from objects.data->tag.
This commit is contained in:
parent
c041e9c630
commit
ca7f240643
|
@ -420,6 +420,8 @@ defmodule Pleroma.Object do
|
|||
hashtag when is_bitstring(hashtag) -> String.downcase(hashtag)
|
||||
end)
|
||||
|> Enum.uniq()
|
||||
# Note: "" elements (plain text) might occur in `data.tag` for incoming objects
|
||||
|> Enum.filter(&(&1 not in [nil, ""]))
|
||||
end
|
||||
|
||||
def object_data_hashtags(_), do: []
|
||||
|
|
17
test/pleroma/hashtag_test.exs
Normal file
17
test/pleroma/hashtag_test.exs
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.HashtagTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Hashtag
|
||||
|
||||
describe "changeset validations" do
|
||||
test "ensure non-blank :name" do
|
||||
changeset = Hashtag.changeset(%Hashtag{}, %{name: ""})
|
||||
|
||||
assert {:name, {"can't be blank", [validation: :required]}} in changeset.errors
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue