Class: Tokite::HookEvent::Issues

Inherits:
BaseEvent show all
Defined in:
app/models/tokite/hook_event/issues.rb

Instance Attribute Summary

Attributes inherited from BaseEvent

#hook_params

Instance Method Summary collapse

Methods inherited from BaseEvent

#initialize, #slack_payload

Constructor Details

This class inherits a constructor from Tokite::HookEvent::BaseEvent

Instance Method Details

#fieldsObject



4
5
6
7
8
9
10
11
12
13
# File 'app/models/tokite/hook_event/issues.rb', line 4

def fields
  {
    event: "issues",
    repo: hook_params[:repository][:full_name],
    title: hook_params[:issue][:title],
    body: hook_params[:issue][:body] || "",
    user: hook_params[:issue][:user][:login],
    label: hook_params[:issue][:labels].map { |label| label[:name] },
  }
end

#notify?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/models/tokite/hook_event/issues.rb', line 15

def notify?
  %w(opened).include?(hook_params[:action])
end

#slack_attachmentObject



23
24
25
26
27
28
29
30
31
# File 'app/models/tokite/hook_event/issues.rb', line 23

def slack_attachment
  {
    title: "##{hook_params[:issue][:number]} #{hook_params[:issue][:title]}",
    title_link: hook_params[:issue][:html_url],
    fallback: "#{hook_params[:issue][:title]}\n#{hook_params[:issue][:body]}",
    text: hook_params[:issue][:body] || "",
    color: "good",
  }
end

#slack_textObject



19
20
21
# File 'app/models/tokite/hook_event/issues.rb', line 19

def slack_text
  "[#{hook_params[:repository][:full_name]}] Issue created by <#{hook_params[:issue][:user][:html_url]}|#{hook_params[:issue][:user][:login]}>"
end