Fix #4544: Show limited view of other user's uploads on the upload index.
* Show completed uploads to other users. * Don't show failed or incomplete uploads to other users. * Don't show tags to other users. * Delete completed uploads after 1 hour. * Delete incomplete uploads after 1 day. * Delete failed uploads after 3 days.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class UploadPolicy < ApplicationPolicy
|
||||
def show?
|
||||
user.is_admin? || record.uploader_id == user.id
|
||||
record.is_completed? || user.is_admin? || record.uploader_id == user.id
|
||||
end
|
||||
|
||||
def batch?
|
||||
@@ -15,9 +15,19 @@ class UploadPolicy < ApplicationPolicy
|
||||
unbanned?
|
||||
end
|
||||
|
||||
def can_view_tags?
|
||||
user.is_admin? || record.uploader_id == user.id
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
%i[file source tag_string rating status parent_id artist_commentary_title
|
||||
artist_commentary_desc referer_url
|
||||
md5_confirmation as_pending translated_commentary_title translated_commentary_desc]
|
||||
end
|
||||
|
||||
def api_attributes
|
||||
attributes = super
|
||||
attributes -= [:tag_string] unless can_view_tags?
|
||||
attributes
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user