Class: Talentio::Notifier::Slack::Interview

Inherits:
Object
  • Object
show all
Defined in:
lib/talentio/notifier/slack/interview.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Interview

Returns a new instance of Interview.



6
7
8
# File 'lib/talentio/notifier/slack/interview.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/talentio/notifier/slack/interview.rb', line 5

def client
  @client
end

Instance Method Details

#notify(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/talentio/notifier/slack/interview.rb', line 10

def notify(data)
  return if data[:type].to_s != "interview"
  # 面接が行われていないものはスキップする
  return unless data[:scheduled_at]

  base_time = Time.parse(data[:scheduled_at])
  diff = base_time.to_i - Time.now.to_i

  # 10分毎にcronで実行される想定
  if (diff < (ENV['TALENTIO_REMIND_INTERVAL'] || 600) && diff >= 0)
    slack_mentions = client.mention_id_from_evaluations(data[:evaluations])
    slack_mentions.each do |m|
      client.chat_postMessage(
        channel: m[:id],
        as_user: false,
        text: "#{base_time.strftime("%Y/%m/%d %H:%M")}からの面接よろしくお願いします!!1",
        attachments: [{
          fields: [
            {
              title: '区分',
              value: data[:requisition_name]
            },
            {
              title: 'url',
              value: data[:candidate_url]
            }
          ],
          color: 'warning'
        }]
      )
    end

    client.chat_postMessage(
      channel: ENV['TELENTIO_SLACK_CHANNEL'] || '#recruiting',
      as_user: false,
      text: "#{base_time.strftime("%Y/%m/%d %H:%M")}からの面接のリマインドをしました",
      attachments: [{
        fields: [
          {
            title: 'インタビュアー',
            value: slack_mentions.map {|m| "#{m[:name]}"}.join(',')
          },
          {
            title: 'url',
            value: data[:candidate_url]
          }
        ],
        color: 'warning'
      }]
    )
  end
end