-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/http callback notification #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # This file is for unifying the coding style for different editors and IDEs | ||
| # editorconfig.org | ||
|
|
||
| root = true | ||
|
|
||
| [*] | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
|
|
||
| [*.{js,rb,less,yml,yaml,jsx,rake}] | ||
| indent_style = space | ||
| indent_size = 2 | ||
|
|
||
| [{package.json,.travis.yml}] | ||
| indent_style = space | ||
| indent_size = 2 | ||
|
|
||
| [*.{css,html}] | ||
| indent_style = tab | ||
| indent_size = 2 | ||
|
|
||
| [*.py] | ||
| indent_style = space | ||
| indent_size = 4 | ||
|
|
||
| [Makefile] | ||
| indent_style = tab | ||
|
|
||
| [*.md] | ||
| trim_trailing_whitespace = false | ||
|
|
||
| [*.{sh,markdown}] | ||
| indent_size = 4 | ||
|
|
||
| [*.go] | ||
| indent_style = tab | ||
| indent_size = 4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| NOTIFICATION_TITLE= | ||
|
|
||
| NOTIFICATION_URL= | ||
|
|
||
| REDIS_URL= | ||
|
|
||
| SLACK_WEBHOOK= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require_relative './base_adapter' | ||
|
|
||
| module RTPush | ||
| class FcmAdapter < RTPush::BaseAdapter | ||
| class << self | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| require_relative './base_adapter' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. |
||
|
|
||
| module RTPush | ||
| class HttpAdapter < RTPush::BaseAdapter | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/Documentation: Missing top-level class documentation comment. |
||
| class << self | ||
| def push(message) | ||
| payload = { | ||
| notification: { | ||
| title: ENV['NOTIFICATION_TITLE'], | ||
| body: message | ||
| } | ||
| } | ||
| http_request(ENV['NOTIFICATION_URL'], 'post', payload) | ||
| rescue StandardError => e | ||
| raise Errors::AdapterError, e.message | ||
| end | ||
|
|
||
| def http_request(url, http_method, payload) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/AbcSize: Assignment Branch Condition size for http_request is too high. [20.47/15] |
||
| uri = URI.parse url.strip | ||
| http = Net::HTTP.new(uri.host, uri.port) | ||
| if uri.scheme == 'https' | ||
| http.use_ssl = true | ||
| http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
| end | ||
| http.open_timeout = 5 | ||
| http.read_timeout = 30 | ||
| # http.set_debug_output($stdout) | ||
| case http_method | ||
| when 'get' | ||
| request = Net::HTTP::Get.new(safe_url(uri.path, uri.query, payload)) | ||
| else | ||
| request = Net::HTTP::Post.new(uri.request_uri) | ||
| request['Content-Type'] = 'application/json' | ||
| request.body = payload.to_json | ||
| end | ||
| http.request(request) | ||
| rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::ReadTimeout, Net::OpenTimeout => e | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [94/80] |
||
| OpenStruct.new(code: 0, body: e.message) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require_relative './base_adapter' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. |
||
|
|
||
| module RTPush | ||
| class InstapushAdapter < RTPush::BaseAdapter | ||
| class << self | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require_relative './base_adapter' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. |
||
|
|
||
| module RTPush | ||
| class RpushAdapter < RTPush::BaseAdapter | ||
| class << self | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require_relative './base_adapter' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. |
||
|
|
||
| module RTPush | ||
| class SlackAdapter < RTPush::BaseAdapter | ||
| class << self | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require_relative './base_adapter' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. |
||
|
|
||
| module RTPush | ||
| class TwilioAdapter < RTPush::BaseAdapter | ||
| class << self | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.