Module: FIR::ThirdNotifierModule

Included in:
Publish
Defined in:
lib/fir/util/third_notifier_module.rb

Instance Method Summary collapse

Instance Method Details

#dingtalk_notifier(download_url, qrcode_path) ⇒ Object



11
12
13
# File 'lib/fir/util/third_notifier_module.rb', line 11

def dingtalk_notifier(download_url, qrcode_path)
  DingtalkHelper.new(@app_info, options, qrcode_path, download_url).send_msg
end

#feishu_notifier(download_url, qrcode_path) ⇒ Object



15
16
17
# File 'lib/fir/util/third_notifier_module.rb', line 15

def feishu_notifier(download_url, qrcode_path)
  FeishuHelper.new(@app_info, options, qrcode_path, download_url).send_msg
end

#notify_to_thirds(download_url, qrcode_path) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/fir/util/third_notifier_module.rb', line 3

def notify_to_thirds(download_url, qrcode_path)
  dingtalk_notifier(download_url, qrcode_path)
  feishu_notifier(download_url, qrcode_path)
  wxwork_notifier(download_url)
rescue => e
  logger.warn "third notifiers error #{e.message}"
end

#wxwork_notifier(download_url) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fir/util/third_notifier_module.rb', line 19

def wxwork_notifier(download_url)
  return if options[:wxwork_webhook].blank? && options[:wxwork_access_token].blank?

  webhook_url = options[:wxwork_webhook]
  webhook_url ||= "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=#{options[:wxwork_access_token]}"

  title = "#{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]}) #{@app_info[:type]}"
  payload = {
    "msgtype": 'news',
    "news": {
      "articles": [{
        "title": "#{title} uploaded",
        "description": "#{title} uploaded at #{Time.now}\nurl: #{download_url}\n#{options[:wxwork_custom_message]}\n",
        "url": download_url,
        "picurl": options[:wxwork_pic_url]
      }]
    }
  }
  DefaultRest.post(webhook_url, payload)
end