users: give all users unlimited favorites.
Let all users have unlimited favorites. Formerly the limit was 10k favorites for regular members, 20k for Gold, and unlimited for Platinum. Limiting favorites doesn't make sense since upvotes are unlimited.
This commit is contained in:
@@ -29,9 +29,7 @@ class Favorite < ApplicationRecord
|
||||
Favorite.transaction do
|
||||
User.where(id: user.id).select("id").lock("FOR UPDATE").first
|
||||
|
||||
if user.favorite_count >= user.favorite_limit
|
||||
raise Error, "You can only keep up to #{user.favorite_limit} favorites. Upgrade your account to save more."
|
||||
elsif Favorite.for_user(user.id).where(:user_id => user.id, :post_id => post.id).exists?
|
||||
if Favorite.for_user(user.id).where(:user_id => user.id, :post_id => post.id).exists?
|
||||
raise Error, "You have already favorited this post"
|
||||
end
|
||||
|
||||
|
||||
@@ -436,16 +436,6 @@ class User < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def favorite_limit(level)
|
||||
if level >= User::Levels::PLATINUM
|
||||
Float::INFINITY
|
||||
elsif level == User::Levels::GOLD
|
||||
20_000
|
||||
else
|
||||
10_000
|
||||
end
|
||||
end
|
||||
|
||||
def favorite_group_limit(level)
|
||||
if level >= User::Levels::BUILDER
|
||||
Float::INFINITY
|
||||
@@ -514,10 +504,6 @@ class User < ApplicationRecord
|
||||
User.tag_query_limit(level)
|
||||
end
|
||||
|
||||
def favorite_limit
|
||||
User.favorite_limit(level)
|
||||
end
|
||||
|
||||
def favorite_group_limit
|
||||
User.favorite_group_limit(level)
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ class UserPolicy < ApplicationPolicy
|
||||
comment_threshold default_image_size
|
||||
favorite_tags blacklisted_tags time_zone per_page
|
||||
custom_style favorite_count statement_timeout favorite_group_limit
|
||||
favorite_limit tag_query_limit max_saved_searches theme
|
||||
tag_query_limit max_saved_searches theme
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
@@ -70,12 +70,6 @@
|
||||
<td>2,000</td>
|
||||
<td>5,000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Favorite Limit</td>
|
||||
<td>10,000</td>
|
||||
<td>20,000</td>
|
||||
<td>Unlimited</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Favorite Groups</td>
|
||||
<td>3</td>
|
||||
@@ -126,14 +120,14 @@
|
||||
<p><%= Danbooru.config.canonical_app_name %> Gold lets you do more
|
||||
complicated searches, and it lets you see hidden tags that non-Gold users
|
||||
can't see. You can search more tags at once, browser deeper in search
|
||||
results, and also keep more favorites, favorite groups, and saved searches.</p>
|
||||
results, and also keep more favorite groups and saved searches.</p>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>What are the benefits of <%= Danbooru.config.canonical_app_name %> Platinum?</summary>
|
||||
|
||||
<p>Platinum is like Gold, but it lets you search even more tags at once,
|
||||
and keep even more favorites, favorite groups, and saved searches.</p>
|
||||
and keep even more favorite groups and saved searches.</p>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
@@ -47,12 +47,5 @@ class FavoriteTest < ActiveSupport::TestCase
|
||||
assert_equal("You have already favorited this post", error.message)
|
||||
assert_equal(1, @user1.favorite_count)
|
||||
end
|
||||
|
||||
should "not allow exceeding the user's favorite limit" do
|
||||
@user1.stubs(:favorite_limit).returns(0)
|
||||
error = assert_raises(Favorite::Error) { @p1.add_favorite!(@user1) }
|
||||
|
||||
assert_equal("You can only keep up to 0 favorites. Upgrade your account to save more.", error.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user