Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6526 Don't reveal if user is banned or suspended when inviting as co-creator #4563

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/models/creatorship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Creatorship < ApplicationRecord
validates_uniqueness_of :pseud, scope: [:creation_type, :creation_id], on: :create

validate :check_invalid, on: :create
validate :check_disallowed, on: :create
validate :check_banned, on: :create
validate :check_disallowed, on: :create
validate :check_approved_becoming_false, on: :update

# Update approval status if this creatorship should be automatically approved.
Expand All @@ -41,24 +41,24 @@ def check_invalid
end
end

# Make sure that the user isn't banned or suspended.
def check_banned
return unless pseud&.user&.banned || pseud&.user&.suspended

errors.add(:base, ts("%{name} cannot be listed as a co-creator.",
name: pseud.byline))
throw :abort
end
JonathanS223 marked this conversation as resolved.
Show resolved Hide resolved

# Make sure that if this is an invitation, we're not inviting someone who has
# disabled invitations.
def check_disallowed
return if approved? || pseud.nil?
return if pseud&.user&.preference&.allow_cocreator

errors.add(:base, ts("%{name} does not allow others to invite them to be a co-creator.",
name: pseud.byline))
end

# Make sure that the user isn't banned or suspended.
def check_banned
return unless pseud&.user&.banned || pseud&.user&.suspended

errors.add(:base, ts("%{name} is currently banned and cannot be listed as a co-creator.",
name: pseud.byline))
end

# Make sure that we're not trying to set approved to false, since that could
# potentially violate some rules about co-creators. (e.g. Having a user
# listed as a chapter co-creator, but not a work co-creator.)
Expand Down
2 changes: 1 addition & 1 deletion features/works/work_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Feature: Create Works
When I fill in "work_collection_names" with ""
And I fill in "pseud_byline" with "badcoauthor"
And I press "Preview"
Then I should see "badcoauthor is currently banned"
Then I should see "badcoauthor cannot be listed as a co-creator"
When I fill in "pseud_byline" with "coauthor"
And I fill in "Additional Tags" with "this is a very long tag more than one hundred characters in length how would this normally even be created"
And I press "Preview"
Expand Down
Loading