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:
evazion
2020-07-13 18:58:40 -05:00
parent 85f464df83
commit ed79b623cc
6 changed files with 31 additions and 13 deletions

View File

@@ -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