mgabdev
2020-01-16 18:24:10 -05:00
parent 292991bf33
commit 7fb0b462e2
13 changed files with 91 additions and 8 deletions

View File

@@ -74,6 +74,17 @@ class Notification < ApplicationRecord
type != :follow_request
end
def mark_read!
user = account.user
is_newer = self.id > (user.last_read_notification || -1)
if is_newer
user.last_read_notification = self.id
user.save!
else false
end
end
class << self
def cache_ids
select(:id, :updated_at, :activity_type, :activity_id)

View File

@@ -38,6 +38,7 @@
# chosen_languages :string is an Array
# created_by_application_id :bigint(8)
# approved :boolean default(TRUE), not null
# last_read_notification :bigint(8)
#
class User < ApplicationRecord