dmails: allow marking dmails as unread.

* Add ability to mark dmails as unread.
* Fix users.unread_dmail_count to not count deleted dmails.
* Fix show action so that API calls don't mark dmails as read.
* Don't show the unread dmail notice on the /dmails page itself.
* Stop using users.has_mail flag.
This commit is contained in:
evazion
2020-01-31 15:47:58 -06:00
parent 067c6a10e7
commit 6468df6d44
12 changed files with 107 additions and 50 deletions

View File

@@ -22,7 +22,7 @@ class DmailsController < ApplicationController
def show
@dmail = Dmail.find(params[:id])
check_privilege(@dmail)
@dmail.mark_as_read!
@dmail.update!(is_read: true) if request.format.html?
respond_with(@dmail)
end
@@ -41,10 +41,8 @@ class DmailsController < ApplicationController
end
def mark_all_as_read
Dmail.visible.unread.each do |x|
x.update_column(:is_read, true)
end
CurrentUser.user.update(has_mail: false, unread_dmail_count: 0)
@dmails = CurrentUser.user.dmails.mark_all_as_read
respond_with(@dmails)
end
private