Files
danbooru/app/helpers/users_helper.rb
evazion 6468df6d44 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.
2020-02-01 15:49:33 -06:00

19 lines
522 B
Ruby

module UsersHelper
def unread_dmail_indicator(user)
"(#{user.unread_dmail_count})" if user.unread_dmail_count > 0
end
def has_unread_dmails?(user)
user.unread_dmail_count > 0 && (cookies[:hide_dmail_notice].to_i < latest_unread_dmail(user).id)
end
def latest_unread_dmail(user)
user.dmails.active.unread.first
end
def email_sig(user)
verifier = ActiveSupport::MessageVerifier.new(Danbooru.config.email_key, serializer: JSON, digest: "SHA256")
verifier.generate(user.id.to_s)
end
end