Added check in PostStatusService for limited posting functionality to users with unconfirmed emails

• Added:
- check in PostStatusService for limited posting functionality to users with unconfirmed emails
- users with unconfirmed emails can not post mentions that are not a reply
- users with unconfirmed emails can not post to a group that is not the introduce yourself group
This commit is contained in:
Developer 2021-02-19 00:08:23 -05:00
parent 2a8ca2cd56
commit da522f8841
1 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class PostStatusService < BaseService
return idempotency_duplicate if idempotency_given? && idempotency_duplicate?
validate_user_confirmation!
validate_similarity!
validate_links!
validate_media!
@ -160,6 +161,19 @@ class PostStatusService < BaseService
raise GabSocial::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && hasVideoOrGif
end
def validate_user_confirmation!
return true if @account.user&.confirmed?
has_mentions = !@text.match(Account::MENTION_RE).nil?
group_id = @options[:group_id]
is_introduce_yourself_group = group_id == "12"
# do not allow statuses with mentions and not reply
raise GabSocial::NotPermittedError if has_mentions && @in_reply_to.nil?
# do not allow statuses with group if not group 12
raise GabSocial::NotPermittedError if !group_id.nil? && !is_introduce_yourself_group
end
def validate_similarity!
raise GabSocial::NotPermittedError if StatusSimilarityService.new.call?(@text, @account.id)
end