Class: Thredded::UserPostNotification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/thredded/user_post_notification.rb

Overview

Delivery records for Thredded::Post notifications.

Class Method Summary collapse

Class Method Details

.create_from_post_and_user(post, user) ⇒ Boolean

Create a user-post notification record for a given post and a user.

Parameters:

Returns:

  • (Boolean)

    true if a new record was created, false otherwise (e.g. if a record had already existed).


19
20
21
22
23
24
25
26
27
# File 'app/models/thredded/user_post_notification.rb', line 19

def self.create_from_post_and_user(post, user)
  create(
    post_id: post.id,
    user_id: user.id,
    notified_at: Time.zone.now
  )
rescue ActiveRecord::RecordNotUnique
  false
end

.notified_user_ids(post) ⇒ Array<Integer>

Returns The IDs of users who were already notified about the given post.

Parameters:

Returns:

  • (Array<Integer>)

    The IDs of users who were already notified about the given post.


11
12
13
# File 'app/models/thredded/user_post_notification.rb', line 11

def self.notified_user_ids(post)
  where(post_id: post.id).pluck(:user_id)
end