Class: InstagramConnect::Message

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

Overview

One message bubble in a DM thread (or a story reply mirrored as a DM).

Constant Summary collapse

DIRECTIONS =
%w[inbound outbound].freeze
STATUSES =
%w[received pending sending sent failed].freeze
KINDS =
%w[dm story_reply story_mention reaction postback share unsupported].freeze
SOURCES =
%w[inbound manual api operator_app].freeze
MEDIA_STATUSES =
%w[none pending downloadable attached unavailable].freeze
PREVIEW_LIMIT =
140

Instance Method Summary collapse

Instance Method Details

#broadcast_refreshObject

Extension point: a host rendering this record live overrides it to re-broadcast current state after a callback-free write (update_all, which the send and media paths both use to stay atomic). A no-op here keeps the gem free of any Turbo dependency.



39
# File 'app/models/instagram_connect/message.rb', line 39

def broadcast_refresh; end

#deleted?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/models/instagram_connect/message.rb', line 45

def deleted?
  deleted_at.present?
end

#inbound?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/models/instagram_connect/message.rb', line 49

def inbound?
  direction == "inbound"
end

#occurred_atObject



41
42
43
# File 'app/models/instagram_connect/message.rb', line 41

def occurred_at
  sent_at || created_at
end

#outbound?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/instagram_connect/message.rb', line 53

def outbound?
  direction == "outbound"
end

#previewObject

Short summary used for the inbox row preview.



58
59
60
61
# File 'app/models/instagram_connect/message.rb', line 58

def preview
  return body.to_s.truncate(PREVIEW_LIMIT) if body.present?
  "[#{kind}]"
end