mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 17:27:16 +08:00
FIX: When user has already hit bookmark limit, do not error for clear_reminder! or other updates (#12658)
We introduced a cap on the number of bookmarks the user can add in be145ccf2f
. However this has caused unintended side effects; when the `jobs/scheduled/bookmark_reminder_notifications.rb` runs we get this error for users who already had more bookmarks than the limit:
> Job exception: Validation failed: Sorry, you have too many bookmarks, visit #{url}/my/activity/bookmarks to remove some.
This is because the `clear_reminder!` call was triggering a bookmark validation, which raised an error because the user already had to many, holding up other reminders.
This PR also adds `max_bookmarks_per_user` hidden site setting (default 2000). This replaces the BOOKMARK_LIMIT const so we can raise it for certain sites.
This commit is contained in:
@ -33,9 +33,7 @@ describe BookmarksController do
|
||||
|
||||
context "if the user reached the max bookmark limit" do
|
||||
before do
|
||||
@old_constant = Bookmark::BOOKMARK_LIMIT
|
||||
Bookmark.send(:remove_const, "BOOKMARK_LIMIT")
|
||||
Bookmark.const_set("BOOKMARK_LIMIT", 1)
|
||||
SiteSetting.max_bookmarks_per_user = 1
|
||||
end
|
||||
|
||||
it "returns failed JSON with a 400 error" do
|
||||
@ -51,14 +49,9 @@ describe BookmarksController do
|
||||
expect(response.status).to eq(400)
|
||||
user_bookmarks_url = "#{Discourse.base_url}/my/activity/bookmarks"
|
||||
expect(response.parsed_body['errors']).to include(
|
||||
I18n.t("bookmarks.errors.too_many", user_bookmarks_url: user_bookmarks_url)
|
||||
I18n.t("bookmarks.errors.too_many", user_bookmarks_url: user_bookmarks_url, limit: SiteSetting.max_bookmarks_per_user)
|
||||
)
|
||||
end
|
||||
|
||||
after do
|
||||
Bookmark.send(:remove_const, "BOOKMARK_LIMIT")
|
||||
Bookmark.const_set("BOOKMARK_LIMIT", @old_constant)
|
||||
end
|
||||
end
|
||||
|
||||
context "if the user already has bookmarked the post" do
|
||||
|
Reference in New Issue
Block a user