Class: InstagramConnect::Comment

Inherits:
ApplicationRecord show all
Defined in:
app/models/instagram_connect/comment.rb

Overview

A comment on one of the account's media objects. Upserted from the comments webhook; moderation state (hidden/replied) is tracked here.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.record(account:, comment_id:, media_id:, text:, from_username:, parent_id: nil) ⇒ Object

Upsert by Meta comment id — the same comment can arrive more than once.



14
15
16
17
18
19
20
# File 'app/models/instagram_connect/comment.rb', line 14

def self.record(account:, comment_id:, media_id:, text:, from_username:, parent_id: nil)
  comment = find_or_initialize_by(comment_id: comment_id)
  comment. = 
  comment.assign_attributes(media_id: media_id, text: text, from_username: from_username, parent_id: parent_id)
  comment.save!
  comment
end

Instance Method Details

#hidden?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/instagram_connect/comment.rb', line 22

def hidden?
  hidden_at.present?
end