Class: InstagramConnect::MessageReaction
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- InstagramConnect::MessageReaction
- Defined in:
- app/models/instagram_connect/message_reaction.rb
Overview
One reaction event on a message. Append-only — see the migration for why current state is a read rather than a column.
Constant Summary collapse
- ACTIONS =
%w[react unreact].freeze
- ACTORS =
%w[customer business].freeze
Class Method Summary collapse
-
.current_for(ig_message_id) ⇒ Object
The reaction currently showing on a message, or nil if the last event was an unreact.
Instance Method Summary collapse
Class Method Details
.current_for(ig_message_id) ⇒ Object
The reaction currently showing on a message, or nil if the last event was an unreact. Reading MAX(reacted_at) rather than trusting arrival order is what makes out-of-order delivery harmless.
22 23 24 25 26 27 |
# File 'app/models/instagram_connect/message_reaction.rb', line 22 def self.current_for() latest = where(ig_message_id: ).chronological.last return nil if latest.nil? || latest.action == "unreact" latest end |
Instance Method Details
#react? ⇒ Boolean
29 30 31 |
# File 'app/models/instagram_connect/message_reaction.rb', line 29 def react? action == "react" end |