Add Rollbar-to-BasecampСhat events posting#15
Conversation
- Removed extra empty string, - Added comment to Web Console config string.
| Rails.application.routes.draw do | ||
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
|
|
||
| namespace :commands, defaults: {format: :json} do |
There was a problem hiding this comment.
Space inside { missing.
Space inside } missing.
| @@ -0,0 +1,12 @@ | |||
| # aws_secret_file: path to *.yml file with AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID if exist | |||
| aws_secret_file = Rails.configuration.service['aws_secret_file'] | |||
| aws_region = Rails.configuration.service['aws_region'] | |||
There was a problem hiding this comment.
Useless assignment to variable - aws_region.
| rescue NoMethodError => e # del. exception handlidg to see errors in console | ||
| return "<strong>Bugsnag parsing error:</strong> #{e}" | ||
| end | ||
| end No newline at end of file |
|
|
||
| private | ||
|
|
||
| def build_message_text(command_parsed) |
There was a problem hiding this comment.
Unused method argument - command_parsed. If it's necessary, use _ or _command_parsed as an argument name to indicate that it won't be used. You can also write as build_message_text(*) if you want the method to accept any arguments but don't care about them.
| @@ -0,0 +1,36 @@ | |||
| class Commands::CommandsController < ApplicationController | |||
There was a problem hiding this comment.
Missing top-level class documentation comment.
Missing frozen string literal comment.
Use nested module/class definitions instead of compact style.
|
|
||
| if amazon_sns_request['Type'].to_s.casecmp('SubscriptionConfirmation') >= 0 | ||
| client.confirm_subscription( | ||
| topic_arn: snstopic_arn, |
There was a problem hiding this comment.
Indent the first parameter one step more than the start of the previous line.
| class Api::Sns::MessagesController < ApplicationController | ||
| skip_before_action :verify_authenticity_token | ||
|
|
||
| def create |
There was a problem hiding this comment.
Assignment Branch Condition size for create is too high. [24.6/15]
Method has too many lines. [13/10]
| @@ -0,0 +1,8 @@ | |||
| class Api::Giphy::MessagesController < ApplicationController | |||
| skip_before_action :verify_authenticity_token | |||
|
|
||
| if amazon_sns_request['Type'].to_s.casecmp('SubscriptionConfirmation') >= 0 | ||
| client.confirm_subscription( | ||
| topic_arn: snstopic_arn, |
| production: | ||
| <<: *default No newline at end of file | ||
| basecampbot_url: <%= ENV["BASECAMPBOT_URL"] %> | ||
| giphy_api_key: <%= ENV["GIPHY_API_KEY"] %> |
| @@ -1,2 +1,14 @@ | |||
| module ApplicationHelper | |||
There was a problem hiding this comment.
let;s create new class, app/models/chatbot.rb:
class Chatbot
class << self
def parse_webhook
# ...
end
def send_message
# ...
end
end
end| @@ -0,0 +1,11 @@ | |||
| # aws_secret_file: path to *.yml file with AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID if exist | |||
There was a problem hiding this comment.
Missing frozen string literal comment.
Line is too long. [91/80]
| @@ -0,0 +1,14 @@ | |||
| class Chatbot | |||
|
|
|||
| @@ -0,0 +1,14 @@ | |||
| class Chatbot | |||
There was a problem hiding this comment.
Missing top-level class documentation comment.
Missing frozen string literal comment.
| class ApplicationController < ActionController::Base | ||
| protect_from_forgery with: :exception | ||
| skip_before_action :verify_authenticity_token, if: :json_request? | ||
|
|
| @@ -0,0 +1,33 @@ | |||
| class Api::Sns::MessagesController < ApplicationController | |||
|
|
|||
| def create | |||
There was a problem hiding this comment.
Assignment Branch Condition size for create is too high. [25.57/15]
Method has too many lines. [13/10]
| @@ -0,0 +1,35 @@ | |||
| class Api::Gitlab::MessagesController < ApplicationController | |||
|
|
|||
There was a problem hiding this comment.
Extra empty line detected at class body beginning.
|
|
||
| def create | ||
| image = Giphy.random(command_params[:command]).image_original_url.to_s | ||
| Chatbot.send_message(command_params[:callback_url], "<img src='#{image}' />") |
| @@ -0,0 +1,7 @@ | |||
| class Api::Giphy::MessagesController < ApplicationController | |||
|
|
|||
There was a problem hiding this comment.
Extra empty line detected at class body beginning.
| @@ -0,0 +1,7 @@ | |||
| class Api::Giphy::MessagesController < ApplicationController | |||
There was a problem hiding this comment.
Missing top-level class documentation comment.
Missing frozen string literal comment.
Use nested module/class definitions instead of compact style.
| @@ -0,0 +1,35 @@ | |||
| class Api::Bugsnag::MessagesController < ApplicationController | |||
|
|
|||
There was a problem hiding this comment.
Extra empty line detected at class body beginning.
| @@ -0,0 +1,14 @@ | |||
| class Chatbot | |||
|
|
|||
There was a problem hiding this comment.
Extra empty line detected at class body beginning.
| @@ -0,0 +1,35 @@ | |||
| class Api::Bugsnag::MessagesController < ApplicationController | |||
There was a problem hiding this comment.
Missing top-level class documentation comment.
Missing frozen string literal comment.
Use nested module/class definitions instead of compact style.
| @@ -0,0 +1,32 @@ | |||
| class Api::Sns::MessagesController < ApplicationController | |||
| def create | |||
There was a problem hiding this comment.
Assignment Branch Condition size for create is too high. [25.57/15]
Method has too many lines. [13/10]
| class Api::Giphy::MessagesController < ApplicationController | ||
| def create | ||
| image = Giphy.random(command_params[:command]).image_original_url.to_s | ||
| Chatbot.send_message(command_params[:callback_url], "<img src='#{image}' />") |
README.md
app/helpers/application_helper.rb - common methods for all controllers. Parse requests, handle exceptions and message sending.
messages_controller.rb - store parsed data and preparing the message.