Fix #4283: Profile no longer viewable through API.
This commit is contained in:
@@ -453,24 +453,6 @@ class User < ApplicationRecord
|
|||||||
@upload_limit ||= UploadLimit.new(self)
|
@upload_limit ||= UploadLimit.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def base_upload_limit
|
|
||||||
if created_at >= 1.month.ago
|
|
||||||
10
|
|
||||||
elsif created_at >= 2.months.ago
|
|
||||||
20
|
|
||||||
elsif created_at >= 3.months.ago
|
|
||||||
30
|
|
||||||
elsif created_at >= 4.months.ago
|
|
||||||
40
|
|
||||||
else
|
|
||||||
50
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_free_upload_slot
|
|
||||||
(posts.where("created_at >= ?", 23.hours.ago).first.try(:created_at) || 23.hours.ago) + 23.hours
|
|
||||||
end
|
|
||||||
|
|
||||||
def tag_query_limit
|
def tag_query_limit
|
||||||
if is_platinum?
|
if is_platinum?
|
||||||
Danbooru.config.base_tag_query_limit * 2
|
Danbooru.config.base_tag_query_limit * 2
|
||||||
@@ -544,7 +526,7 @@ class User < ApplicationRecord
|
|||||||
module ApiMethods
|
module ApiMethods
|
||||||
def api_attributes
|
def api_attributes
|
||||||
attributes = %i[
|
attributes = %i[
|
||||||
id created_at name inviter_id level base_upload_limit
|
id created_at name inviter_id level
|
||||||
post_upload_count post_update_count note_update_count is_banned
|
post_upload_count post_update_count note_update_count is_banned
|
||||||
can_approve_posts can_upload_free is_super_voter level_string
|
can_approve_posts can_upload_free is_super_voter level_string
|
||||||
]
|
]
|
||||||
@@ -559,7 +541,7 @@ class User < ApplicationRecord
|
|||||||
api_burst_limit remaining_api_limit statement_timeout
|
api_burst_limit remaining_api_limit statement_timeout
|
||||||
favorite_group_limit favorite_limit tag_query_limit
|
favorite_group_limit favorite_limit tag_query_limit
|
||||||
can_comment_vote? can_remove_from_pools? is_comment_limited?
|
can_comment_vote? can_remove_from_pools? is_comment_limited?
|
||||||
can_comment? can_upload? max_saved_searches theme
|
can_comment? max_saved_searches theme
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -573,7 +555,7 @@ class User < ApplicationRecord
|
|||||||
artist_commentary_version_count pool_version_count
|
artist_commentary_version_count pool_version_count
|
||||||
forum_post_count comment_count favorite_group_count
|
forum_post_count comment_count favorite_group_count
|
||||||
appeal_count flag_count positive_feedback_count
|
appeal_count flag_count positive_feedback_count
|
||||||
neutral_feedback_count negative_feedback_count upload_limit
|
neutral_feedback_count negative_feedback_count
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
|||||||
context "show action" do
|
context "show action" do
|
||||||
setup do
|
setup do
|
||||||
# flesh out profile to get more test coverage of user presenter.
|
# flesh out profile to get more test coverage of user presenter.
|
||||||
@user = create(:banned_user, can_approve_posts: true, is_super_voter: true)
|
@user = create(:banned_user, can_approve_posts: true, is_super_voter: true, created_at: 2.weeks.ago)
|
||||||
as_user do
|
as_user do
|
||||||
create(:saved_search, user: @user)
|
create(:saved_search, user: @user)
|
||||||
create(:post, uploader: @user, tag_string: "fav:#{@user.name}")
|
create(:post, uploader: @user, tag_string: "fav:#{@user.name}")
|
||||||
@@ -71,7 +71,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
|||||||
xml = Hash.from_xml(response.body)
|
xml = Hash.from_xml(response.body)
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal(false, xml["user"]["can_upload"])
|
assert_equal(false, xml["user"]["enable_safe_mode"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user