Class: Slk::Services::MessageResolver
- Inherits:
-
Object
- Object
- Slk::Services::MessageResolver
- Defined in:
- lib/slk/services/message_resolver.rb
Overview
Resolves and fetches individual messages by timestamp from channels Used by activity feed, saved items, and other features that need to fetch message content by ts.
Instance Method Summary collapse
-
#fetch_by_ts(channel_id, message_ts) ⇒ Hash?
Fetch a single message by its timestamp from a channel.
-
#initialize(conversations_api:, on_debug: nil) ⇒ MessageResolver
constructor
A new instance of MessageResolver.
Constructor Details
#initialize(conversations_api:, on_debug: nil) ⇒ MessageResolver
Returns a new instance of MessageResolver.
9 10 11 12 |
# File 'lib/slk/services/message_resolver.rb', line 9 def initialize(conversations_api:, on_debug: nil) @api = conversations_api @on_debug = on_debug end |
Instance Method Details
#fetch_by_ts(channel_id, message_ts) ⇒ Hash?
Fetch a single message by its timestamp from a channel
18 19 20 21 22 23 24 25 26 |
# File 'lib/slk/services/message_resolver.rb', line 18 def fetch_by_ts(channel_id, ) response = (channel_id, ) return nil unless response['ok'] && response['messages']&.any? response['messages'].find { |msg| msg['ts'] == } rescue ApiError => e @on_debug&.call("Could not fetch message #{} from #{channel_id}: #{e.}") nil end |