Class: Thredded::MarkAllRead

Inherits:
Object
  • Object
show all
Defined in:
app/commands/thredded/mark_all_read.rb

Class Method Summary collapse

Class Method Details

.run(user) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'app/commands/thredded/mark_all_read.rb', line 5

def self.run(user)
  unread_topics = Thredded::PrivateTopic.unread(user)
  return if unread_topics.empty?

  unread_topics.each do |topic|
    last_post = topic.posts.order_oldest_first.last

    Thredded::UserPrivateTopicReadState.touch!(user.id, topic.id, last_post)
  end
end