diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-12-12 11:10:11 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-12-12 11:10:11 -0600 |
commit | 16332682931d3a59c180ecff94e07d6bf650e5e0 (patch) | |
tree | 151788b9589179ead99e1bf1e86ae0dbe515c7e3 /app/services | |
parent | 5cf03910f7c40d4683dc6c10dcab9294df566f09 (diff) |
avoid posting when body only has mentions it
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/post_status_service.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index dc1a3bcdc..2fe1f3e56 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -55,6 +55,7 @@ class PostStatusService < BaseService raise Mastodon::LengthValidationError, I18n.t('statuses.replies_rejected') if recipient_rejects_replies? raise Mastodon::LengthValidationError, I18n.t('statuses.kicked') if kicked? + raise Mastodon::LengthValidationError, I18n.t('statuses.no_body') if has_only_mentions? return idempotency_duplicate if idempotency_given? && idempotency_duplicate? @@ -98,6 +99,10 @@ class PostStatusService < BaseService @in_reply_to.present? && ConversationKick.where(account_id: @account.id, conversation_id: @in_reply_to.conversation_id).exists? end + def has_only_mentions? + @options[:nomentions].blank? && @text.match?(/^(?:\s*@((#{Account::USERNAME_RE})(?:@[a-z0-9\.\-]+[a-z0-9]+)?))+$/i) + end + def mark_recipient_known @in_reply_to.account.mark_known! unless !Setting.auto_mark_known || @in_reply_to.account.known? end |