mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 11:28:18 +00:00
Since the system user is a regular user, it can have its `allow_private_messages` user option turned off, which with our current `can_send_private_message?(Discourse.system_user)` check inside the CurrentUserSerializer, will prevent any user from sending messages in the UI if the system user is not accepting PMs. This commit adds a new `can_send_private_messages?` method to the Guardian, which can be used in serializers and not depend on the system user. When the user actually sends a message we still rely on the old `can_send_private_message?(target)` call to see if they are allowed to send the message to the target. The new method is just to say they can "generally" send private messages.