expo-push-middleware 0.1.3 → 0.1.4

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: 672ee14933ca043e753e612bbdbc5a6e77baec55f90e33a4ce3c395607c3841f
4
- data.tar.gz: 4e2336dbdfc85be8b9331091c4ca45790211f1a1bcd0ff281cc85347d5b92e48
3
+ metadata.gz: '04068aa86c30613188a0bc722db4cc4567ef319cd19fe105bed1d3973931ba2f'
4
+ data.tar.gz: 9581bc9ddedb6cb6dbc6eb39a490ef735530aca6d810b958bafd17984086d9b1
5
5
  SHA512:
6
- metadata.gz: 88f7093a7c7223186e6f141450c54ff9414af9483a04ec3d9f2aaf3df58dfed365e64f0dbeee4870255b0fb94adcd4e2bf70813be911ac073221bea4ad561e5f
7
- data.tar.gz: cf1369fad7e4ace1c5dcf8ce70f3715aba95b9c1c4165185b6cb7fb59ab65d6306b049e66c8e38d7b8048200b7b2f1e4712c6cb92eb2f45408b5ae4051378f80
6
+ metadata.gz: c2bbfb95f52ec615a3711739c5a4c4c4687be5d6499d61b1e2bf77ad59aa0059a9d06a4f875661f16d9c262c865d84d88b39bde0afff4cc0779ecdab49404302
7
+ data.tar.gz: 5ed3c6a7bc08c8205b016af82e64fa7ebf96dbe1f51effbf05409c16249044fa1ab81ff70fb9fef844dbe8351aaeb00592fc4cebf2d737160680e7bdc2003e88
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2023-03-31
4
+
5
+ - Raise error when request has more than 100 targetted devices
6
+
7
+ Expo SDK just breaks without handling errors in this situation.
8
+
9
+ ## [0.1.3] - 2023-03-31
10
+
11
+ - Require Typhoeus & Json classes.
12
+
13
+ Missing requires led to uninitialized constant errors in some cases.
14
+
3
15
  ## [0.1.1] - 2023-03-29
4
16
 
5
17
  - Fix typo in filename
@@ -3,7 +3,7 @@
3
3
  module Expo
4
4
  module Push
5
5
  module Middleware
6
- VERSION = "0.1.3"
6
+ VERSION = "0.1.4"
7
7
  end
8
8
  end
9
9
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "expo-push-middleware/version"
4
+ require 'active_support/core_ext/hash/indifferent_access'
4
5
  require 'typhoeus'
5
6
  require 'json'
6
7
 
@@ -21,13 +22,18 @@ module Expo
21
22
  class Client
22
23
  class Error < StandardError; end
23
24
 
25
+ class TooManyMessagesError < StandardError
26
+ end
27
+
24
28
  def initialize(**args)
25
29
  @http_client = args[:http_client] || Typhoeus
26
30
  end
27
31
 
28
32
  def send_messages(messages, **_)
29
33
  # https://docs.expo.io/versions/latest/guides/push-notifications/#message-format
30
- raise TooManyMessagesError, "Only 100 message objects at a time allowed." if messages.length > 100
34
+ expo_tokens = messages.map { |message| message.with_indifferent_access[:to] }.flatten
35
+ raise TooManyMessagesError, "Only 100 message objects at a time allowed." if expo_tokens.length > 100
36
+
31
37
 
32
38
  @http_client.post(
33
39
  "#{Expo::Push::Middleware.config.api_url}/api/v1/push_requests",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expo-push-middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Camblan
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Middleware that intercepts push notifications, sends them to Expo Push
28
42
  API with monitoring as bonus.
29
43
  email: