Class: InstagramConnect::Mention
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- InstagramConnect::Mention
- Defined in:
- app/models/instagram_connect/mention.rb
Overview
An @mention of the account, in a comment, a caption or a tag.
Meta does not store these notifications and will not resend them, so this table is the only record that a mention ever happened.
Constant Summary collapse
- KINDS =
%w[comment caption tag story].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.record(account:, kind:, mentioned_at:, ig_media_id: nil, comment_id: nil, **attributes) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/instagram_connect/mention.rb', line 20 def self.record(account:, kind:, mentioned_at:, ig_media_id: nil, comment_id: nil, **attributes) mention = find_or_initialize_by( account_id: account.id, kind: kind, ig_media_id: ig_media_id.presence, comment_id: comment_id.presence ) mention.assign_attributes(attributes.compact.merge(mentioned_at: mentioned_at)) mention.save! mention rescue ActiveRecord::RecordNotUnique find_by!(account_id: account.id, kind: kind, ig_media_id: ig_media_id.presence, comment_id: comment_id.presence) end |
Instance Method Details
#answered? ⇒ Boolean
33 34 35 |
# File 'app/models/instagram_connect/mention.rb', line 33 def answered? replied_at.present? end |