dmails: replace hard deletions with soft deletions.

Turn deletions into soft deletions (set the is_deleted flag) instead of
hard deletions (remove from database). The is_deleted flag actually
already existed, but it was never used before.
This commit is contained in:
evazion
2020-01-30 21:49:55 -06:00
parent 5df8d08aae
commit f8db577c25
7 changed files with 26 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
class DmailsController < ApplicationController
respond_to :html, :xml, :js, :json
before_action :member_only, except: [:index, :show, :update, :destroy, :mark_all_as_read]
before_action :member_only, except: [:index, :show, :update, :mark_all_as_read]
def new
if params[:respond_to_id]
@@ -18,7 +18,8 @@ class DmailsController < ApplicationController
if params[:folder] && params[:set_default_folder]
cookies.permanent[:dmail_folder] = params[:folder]
end
@dmails = Dmail.active.visible.paginated_search(params, count_pages: true)
@dmails = Dmail.visible.paginated_search(params, defaults: { is_spam: false, is_deleted: false }, count_pages: true)
respond_with(@dmails)
end
@@ -43,14 +44,6 @@ class DmailsController < ApplicationController
respond_with(@dmail)
end
def destroy
@dmail = Dmail.find(params[:id])
check_privilege(@dmail)
@dmail.mark_as_read!
@dmail.destroy
redirect_to dmails_path, :notice => "Message destroyed"
end
def mark_all_as_read
Dmail.visible.unread.each do |x|
x.update_column(:is_read, true)