Class: CodeBuildNotifier::SlackSender
- Inherits:
-
Object
- Object
- CodeBuildNotifier::SlackSender
- Defined in:
- lib/codebuild-notifier/slack_sender.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #find_alias(email) ⇒ Object
-
#initialize(config) ⇒ SlackSender
constructor
A new instance of SlackSender.
- #send(message) ⇒ Object
Constructor Details
#initialize(config) ⇒ SlackSender
Returns a new instance of SlackSender.
25 26 27 |
# File 'lib/codebuild-notifier/slack_sender.rb', line 25 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/codebuild-notifier/slack_sender.rb', line 23 def config @config end |
Instance Method Details
#find_alias(email) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/codebuild-notifier/slack_sender.rb', line 79 def find_alias(email) config.slack_alias_table && config.dynamo_client.get_item( table_name: config.slack_alias_table, key: { 'alternate_email' => email } ).item&.fetch('workspace_email') end |
#send(message) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/codebuild-notifier/slack_sender.rb', line 29 def send() Slack.configure { |slack_config| slack_config.token = app_token } channel = .additional_channel if channel channel = "##{channel}" unless /\A#/.match?(channel) (, channel) end user_ids = .recipients.map { |email| find_slack_user(email)&.id } user_ids.uniq.compact.each { |user_id| (, user_id) } end |