mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 08:53:46 +08:00
be145ccf2f
Adds a bookmark search per page limit, a total bookmark creation limit, and a rate limit per day for bookmark creation.
31 lines
642 B
Ruby
31 lines
642 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserBookmarkList
|
|
include ActiveModel::Serialization
|
|
|
|
PER_PAGE = 20
|
|
|
|
attr_reader :bookmarks, :per_page
|
|
attr_accessor :more_bookmarks_url
|
|
|
|
def initialize(user:, guardian:, params:)
|
|
@user = user
|
|
@guardian = guardian
|
|
@params = params
|
|
|
|
@params.merge!(per_page: PER_PAGE) if params[:per_page].blank?
|
|
@params[:per_page] = PER_PAGE if @params[:per_page] > PER_PAGE
|
|
|
|
@bookmarks = []
|
|
end
|
|
|
|
def load
|
|
@bookmarks = BookmarkQuery.new(user: @user, guardian: @guardian, params: @params).list_all
|
|
@bookmarks
|
|
end
|
|
|
|
def per_page
|
|
@per_page ||= @params[:per_page]
|
|
end
|
|
end
|