mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 15:05:45 +00:00
Fix enforcement of character limits
This commit is contained in:
parent
423cfaf141
commit
f8dc597c51
|
@ -591,7 +591,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
limit = Pleroma.Config.get([:instance, :limit])
|
||||
length = String.length(full_payload)
|
||||
|
||||
if length < limit do
|
||||
if length <= limit do
|
||||
:ok
|
||||
else
|
||||
{:error, dgettext("errors", "The status is over the character limit")}
|
||||
|
|
|
@ -202,13 +202,15 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
CommonAPI.post(user, %{"status" => ""})
|
||||
end
|
||||
|
||||
test "it returns error when character limit is exceeded" do
|
||||
test "it validates character limits are correctly enforced" do
|
||||
Pleroma.Config.put([:instance, :limit], 5)
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
assert {:error, "The status is over the character limit"} =
|
||||
CommonAPI.post(user, %{"status" => "foobar"})
|
||||
|
||||
assert {:ok, activity} = CommonAPI.post(user, %{"status" => "12345"})
|
||||
end
|
||||
|
||||
test "it can handle activities that expire" do
|
||||
|
|
Loading…
Reference in a new issue