Class: Dingding::Notifier::PayloadMiddleware::FormatText

Inherits:
Base
  • Object
show all
Defined in:
lib/dingding-notifier/payload_middleware/format_text.rb

Instance Attribute Summary

Attributes inherited from Base

#notifier, #options

Instance Method Summary collapse

Methods inherited from Base

default_opts, #initialize, middleware_name, options

Constructor Details

This class inherits a constructor from Dingding::Notifier::PayloadMiddleware::Base

Instance Method Details

#call(payload = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/dingding-notifier/payload_middleware/format_text.rb', line 22

def call payload={}
  
  return payload unless payload[:format_text]
  tmp = options[:formats].dup
  tmp[:at][:atMobiles] = payload[:atMobiles] if payload.has_key?(:atMobiles)
  tmp[:at][:atUserIds] = payload[:atUserIds] if payload.has_key?(:atUserIds)
  tmp[:at][:isAtAll] = payload[:isAtAll] if payload.has_key?(:isAtAll)
  tmp[:text][:content] = payload[:format_text][:text].to_s if payload.has_key?(:format_text)
  tmp
end