Class: SlackController

Inherits:
ApplicationController show all
Defined in:
lib/nexmo_developer/app/controllers/slack_controller.rb

Constant Summary

Constants included from ApplicationHelper

ApplicationHelper::CONFIG

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_admin!, #not_found, #redirect_vonage_domain

Methods included from ApplicationHelper

#active_sidenav_item, #canonical_base, #canonical_base_from_config, #canonical_path, #canonical_url, #dashboard_cookie, #search_enabled?, #set_utm_cookie, #theme

Instance Method Details

#inviteObject



9
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
# File 'lib/nexmo_developer/app/controllers/slack_controller.rb', line 9

def invite
  response = RestClient.post "https://#{ENV['SLACK_SUBDOMAIN']}.slack.com/api/users.admin.invite", {
    token: ENV['SLACK_TOKEN'],
    email: @email,
  }

  response = JSON.parse(response)

  if response['ok']
    @invitation_sent_successfully = true
    @notice = "An invitation has been sent to #{@email}"
  else
    case response['error']
    when 'already_invited'
      @notice = "It looks like you've already been sent an invitation."
    when 'already_in_team'
      @notice = 'You are already a member of this Slack'
    else
      Bugsnag.notify('Slack Error') do |notification|
        notification.add_tab(:slack, { response: response })
      end
      @notice = 'Something went wrong. Please try again later.'
    end
  end

  render 'join'
end

#joinObject



7
# File 'lib/nexmo_developer/app/controllers/slack_controller.rb', line 7

def join; end