simplepush 0.7.3 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 944a922fb181faca66ccccba275e8ba657caeab4b7bc76106e08a11c1ec82028
4
- data.tar.gz: 40ccc6113776962b51b9e09cd24274317a162cd6101f58e72d8cb276c06209e1
3
+ metadata.gz: ff60e8ee85628a56967349ef99517e7c0a82bc241bb977e4c9ccb798fbe67906
4
+ data.tar.gz: 5de8f447389e3f82001513c0c1fc08c4bb41d743b9203dca70bdbf54a349b1d7
5
5
  SHA512:
6
- metadata.gz: cdc4c3d2d9150792feb3f88113a8b7d6709a119cda4f4234613e2b58126e285acb0dae8c746c6ff15e4569dd37d7c00675d623b1ae28c2ae9047b161ccda3baf
7
- data.tar.gz: c3f2ae9b609b76b9b03834d8d43167c9767b46c3c8abd489288797743b8dab4065b3ded7065bab41ee4502d30f151c7989960bfb6bc69ad66cc809d856f45732
6
+ metadata.gz: 0b715d506a227e7c72c997636733ccc43807695a1a07fd26b6a85e2b52ceff6d4e9245eff2da32129b7a5f689682844c8e9fde4ece1e5ff6363385164d3af5ef
7
+ data.tar.gz: e4a70aa09237fc24db24fe39a48b0a34755fd8198989821d0d9d62695c0da644fc2532261fff8eafd3db460914df2ea26cdcc8533e3f50733f9b78b9cd1ae165
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simplepush (0.7.3)
4
+ simplepush (0.7.5)
5
5
  httparty
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -144,6 +144,8 @@ The following is a sample of the query as it is produced:
144
144
  - 0.7.1 Fixed incorrect content-type handling.
145
145
  - 0.7.2 Bump dependencies because of vulnerability in httparty
146
146
  - 0.7.3 Fix OpenSSL cipher needing key again under Ruby >= 3.0, bump dependencies
147
+ - 0.7.4 Fix message length restrictions for Exception Notification
148
+ - 0.7.5 Make more robust again missing credentials
147
149
 
148
150
  ## Contributing
149
151
 
@@ -9,13 +9,21 @@ module ExceptionNotifier
9
9
 
10
10
  def initialize(options)
11
11
  cred = Rails.application.credentials.simplepush
12
+
13
+ if !cred
14
+ Rails.logger.error "Simplepush credentials not found. Please add simplepush credentials to your credentials file."
15
+ return
16
+ end
17
+
12
18
  @client = Simplepush.new(cred[:key], cred[:pass], cred[:salt])
13
19
  @default_options = options
14
20
  end
15
21
 
16
22
  def call(exception, options = {})
17
- event = SimplepushExceptionEvent.new(exception, options.reverse_merge(default_options))
18
- @client.send(event.formatted_title, event.formatted_body)
23
+ if !@client
24
+ event = SimplepushExceptionEvent.new(exception, options.reverse_merge(default_options))
25
+ @client.send(event.formatted_title, event.formatted_body)
26
+ end
19
27
  end
20
28
 
21
29
  #
@@ -32,6 +40,7 @@ module ExceptionNotifier
32
40
  MAX_TITLE_LENGTH = 120
33
41
  MAX_VALUE_LENGTH = 300
34
42
  MAX_BACKTRACE_SIZE = 3
43
+ MAX_TOTAL_SIZE_BYTES = 1024
35
44
 
36
45
  attr_reader :exception,
37
46
  :options
@@ -71,7 +80,21 @@ module ExceptionNotifier
71
80
  text << formatted_request if request
72
81
  text << formatted_session if request
73
82
 
74
- text.join("\n------------------\n")
83
+ text = text.join("\n------------------\n")
84
+
85
+ if text.bytesize >= MAX_TOTAL_SIZE_BYTES
86
+ # puts "Text is too long (#{text.bytesize} bytes >= MAX_TOTAL_SIZE), need to truncate"
87
+
88
+ # if truncate bytes is available
89
+ if text.respond_to?(:truncate_bytes) && false
90
+ text = text.truncate_bytes(MAX_TOTAL_SIZE_BYTES)
91
+ else
92
+ text = text[0...(MAX_TOTAL_SIZE_BYTES/2)]
93
+ end
94
+ # puts "Text after truncate is #{text.bytesize} bytes <= MAX_TOTAL_SIZE"
95
+ end
96
+
97
+ text
75
98
  end
76
99
 
77
100
  def formatted_key_value(key, value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Simplepush
4
- VERSION = "0.7.3"
4
+ VERSION = "0.7.5"
5
5
  end
data/lib/simplepush.rb CHANGED
@@ -30,6 +30,8 @@ class Simplepush
30
30
  #
31
31
  # This method is blocking.
32
32
  #
33
+ # Returns the response object from Httparty.
34
+ #
33
35
  def send(title, message, event = nil)
34
36
  raise "Key and message argument must be set" unless message
35
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplepush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Oezbek
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-21 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty