|> validate_inclusion(:type, ["ChatMessage"])
|> validate_required([:id, :actor, :to, :type, :content])
|> validate_length(:to, is: 1)
+ |> validate_length(:content, max: Pleroma.Config.get([:instance, :remote_limit]))
|> validate_local_concern()
end
describe "chat messages" do
setup do
+ clear_config([:instance, :remote_limit])
user = insert(:user)
recipient = insert(:user, local: false)
assert {:ok, _object, _meta} = ObjectValidator.validate(valid_chat_message, [])
end
+ test "does not validate if the message is longer than the remote_limit", %{
+ valid_chat_message: valid_chat_message
+ } do
+ Pleroma.Config.put([:instance, :remote_limit], 2)
+ refute match?({:ok, _object, _meta}, ObjectValidator.validate(valid_chat_message, []))
+ end
+
test "does not validate if the actor or the recipient is not in our system", %{
valid_chat_message: valid_chat_message
} do