Not a bug Conversation Validations Still Being Performed on Conversations with setIsAutomated

Snog

Well-known member
Affected version
2.1.9
If you send a PC to a user that doesn't have permission to receive new conversations, and setIsAutomated() is used, validations still take place and this error is thrown...
Code:
Cannot save with validation errors. Use validate() to ensure there are no errors. (First error: You may not start a conversation with the following recipients: TestUser.) src/XF/Service/ValidateAndSavableTrait.php:34
 
setIsAutomated simply prevents setting an IP (because it may not be the IP address of the actual user who is creating the message), it prevents the spam check and it prevents message validity checks such as the maximum message length and others.

It does not prevent other validations taking place. In this case, it is failing to validate the recipients you are sending the message to. These validations should nearly always be performed regardless.

You can, however, bypass those by using Creator::setRecipientsTrusted() rather than Creator::setRecipients() or you can call Creator::setRecipients() with the second and third arguments set to false.
 
Back
Top Bottom