This commit is contained in:
benji 2015-04-04 02:50:26 +02:00
parent 48236e1f69
commit 8e5ccfed7a
2 changed files with 10 additions and 4 deletions

View file

@ -21,11 +21,14 @@ module ApplicationHelper
def slack_notification(user, message) def slack_notification(user, message)
require 'net/http' require 'net/http'
require 'json' require 'json'
postData = Net::HTTP.post_form(URI.parse('https://slack.com/api/users.list'), {'token'=>'xoxp-2484654576-2817526333-4116062828-04487a'}) postData = Net::HTTP.post_form(URI.parse('https://slack.com/api/users.list'), {'token'=>Rails.application.secrets.access_token})
slackmember = JSON.parse(postData.body)["members"].select{ |m| m["profile"]["email"] == user.uid + "@zeus.ugent.be" }.first data = JSON.parse(postData.body)
if data["ok"]
slackmember = data["members"].select{ |m| m["profile"]["email"] == user.uid + "@zeus.ugent.be" }.first
if slackmember if slackmember
Webhook.new(channel: "@" + slackmember["name"], username: "Tab").ping(message) Webhook.new(channel: "@" + slackmember["name"], username: "Tab").ping(message)
end
end end
end end
end end

View file

@ -15,10 +15,12 @@ development:
omniauth_client_id: tomtest omniauth_client_id: tomtest
omniauth_client_secret: blargh omniauth_client_secret: blargh
zeus_token: "token" zeus_token: "token"
access_token: "token"
test: test:
secret_key_base: 961437e28e7d6055ffaad9cf1f8d614354f57f10cb2d7601c9d6ede72a03b9c9535ad9e63507e3eb31252c4895970a63117493408f2e9a46c7a0c4a5a7836b81 secret_key_base: 961437e28e7d6055ffaad9cf1f8d614354f57f10cb2d7601c9d6ede72a03b9c9535ad9e63507e3eb31252c4895970a63117493408f2e9a46c7a0c4a5a7836b81
zeus_token: "token" zeus_token: "token"
access_token: "token"
# Do not keep production secrets in the repository, # Do not keep production secrets in the repository,
# instead read values from the environment. # instead read values from the environment.
@ -27,3 +29,4 @@ production:
omniauth_client_id: "" omniauth_client_id: ""
omniauth_client_secret: "" omniauth_client_secret: ""
zeus_token: "" zeus_token: ""
access_token: ""