Class: Slk::Formatters::JsonMessageFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/slk/formatters/json_message_formatter.rb

Overview

Formats Slack messages as JSON for structured output

Instance Method Summary collapse

Constructor Details

#initialize(cache_store:) ⇒ JsonMessageFormatter

Returns a new instance of JsonMessageFormatter.



7
8
9
# File 'lib/slk/formatters/json_message_formatter.rb', line 7

def initialize(cache_store:)
  @cache = cache_store
end

Instance Method Details

#format(message, workspace: nil, options: {}) ⇒ Object

Format a message as a JSON-serializable hash



12
13
14
15
16
17
18
19
20
# File 'lib/slk/formatters/json_message_formatter.rb', line 12

def format(message, workspace: nil, options: {})
  result = build_base_result(message)
  result[:reactions] = format_reactions(message.reactions, workspace, options)

  add_user_name(result, message, workspace, options)
  add_channel_info(result, workspace, options)

  result
end