2016-06-09 08:39:16 -04:00
|
|
|
# rubocop:disable all
|
2014-10-06 10:50:24 -04:00
|
|
|
class MoveSlackServiceToWebhook < ActiveRecord::Migration
|
|
|
|
def change
|
|
|
|
SlackService.all.each do |slack_service|
|
|
|
|
if ["token", "subdomain"].all? { |property| slack_service.properties.key? property }
|
|
|
|
token = slack_service.properties['token']
|
|
|
|
subdomain = slack_service.properties['subdomain']
|
|
|
|
webhook = "https://#{subdomain}.slack.com/services/hooks/incoming-webhook?token=#{token}"
|
|
|
|
slack_service.properties['webhook'] = webhook
|
|
|
|
slack_service.properties.delete('token')
|
|
|
|
slack_service.properties.delete('subdomain')
|
|
|
|
# Room is configured on the Slack side
|
|
|
|
slack_service.properties.delete('room')
|
2015-02-25 12:22:08 -05:00
|
|
|
slack_service.save(validate: false)
|
2014-10-06 10:50:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|