Class: ChatNotifier::ThreadStore::SlackMetadata
- Inherits:
-
ChatNotifier::ThreadStore
- Object
- ChatNotifier::ThreadStore
- ChatNotifier::ThreadStore::SlackMetadata
- Defined in:
- lib/chat_notifier/thread_store/slack_metadata.rb
Overview
Uses the Slack channel itself as the store: parents are posted with message metadata carrying the thread key; find scans recent history.
Constant Summary collapse
- EVENT_TYPE =
"chat_notifier_thread"- HISTORY_URL =
"https://slack.com/api/conversations.history"- HISTORY_LIMIT =
200
Instance Attribute Summary collapse
-
#chatter ⇒ Object
readonly
Returns the value of attribute chatter.
Instance Method Summary collapse
- #find(key, process: nil) ⇒ Object
-
#initialize(chatter:) ⇒ SlackMetadata
constructor
A new instance of SlackMetadata.
-
#record(key, ref) ⇒ Object
Posting the parent with metadata is the record; nothing separate to do.
Constructor Details
#initialize(chatter:) ⇒ SlackMetadata
Returns a new instance of SlackMetadata.
12 13 14 |
# File 'lib/chat_notifier/thread_store/slack_metadata.rb', line 12 def initialize(chatter:) @chatter = chatter end |
Instance Attribute Details
#chatter ⇒ Object (readonly)
Returns the value of attribute chatter.
16 17 18 |
# File 'lib/chat_notifier/thread_store/slack_metadata.rb', line 16 def chatter @chatter end |
Instance Method Details
#find(key, process: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chat_notifier/thread_store/slack_metadata.rb', line 18 def find(key, process: nil) response = fetch_history(process) unless response["ok"] ChatNotifier.logger.error( "ChatNotifier: thread lookup failed: #{response.fetch("error", "unrecognized response")}" ) return nil end = (response, key) return nil unless ThreadRef.new(ts: ["ts"], status: .dig("metadata", "event_payload", "status")) rescue => error # A failed lookup must never abort posting the notification itself. ChatNotifier.logger.error("ChatNotifier: thread lookup failed: #{error.}") nil end |
#record(key, ref) ⇒ Object
Posting the parent with metadata is the record; nothing separate to do.
37 |
# File 'lib/chat_notifier/thread_store/slack_metadata.rb', line 37 def record(key, ref) = nil |