Skip to content

Commit 0b2410b

Browse files
committed
remove payload alidation for the client lib, this is done by the server
also remove upper bound check on the number of interests
1 parent 56218ea commit 0b2410b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ The native notifications API is hosted at `nativepush-cluster1.pusher.com` and o
262262

263263
You can send pushes by using the `notify` method, either globally or on the instance. The method takes two parameters:
264264

265-
- `interests`: An Array of strings which represents the interests your devices are subscribed to. These are akin to channels in the DDN with less of an epehemeral nature. Note that currently, you can only send to _one_ interest.
265+
- `interests`: An Array of strings which represents the interests your devices are subscribed to. These are akin to channels in the DDN with less of an epehemeral nature. Note that currently, you can only publish to, at most, _ten_ interests.
266266
- `data`: The content of the notification represented by a Hash. You must supply either the `gcm` or `apns` key. For a detailed list of the acceptable keys, take a look at the [iOS](https://pusher.com/docs/push_notifications/ios/server) and [Android](https://pusher.com/docs/push_notifications/android/server) docs.
267267

268268
Example:

lib/pusher/native_notification/client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ def notify(interests, data = {})
4242
# @return [String]
4343
def payload(interests, data)
4444
interests = Array(interests).map(&:to_s)
45-
raise Pusher::Error, "Too many interests provided" if interests.length > 1
46-
data = deep_symbolize_keys!(data).merge(interests: interests)
45+
46+
raise Pusher::Error, "Interests array must not be empty" if interests.length == 0
47+
48+
data = deep_symbolize_keys!(data)
49+
50+
data.merge!(interests: interests)
51+
4752
MultiJson.encode(data)
4853
end
4954

spec/client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@
550550
expect(@client.notification_host).to eq(@client.notification_client.host)
551551
end
552552

553-
it "should raise an error if more than one interest is provided" do
553+
it "should raise an error if no interest is provided" do
554554
payload = {
555555
gcm: {
556556
notification: {
@@ -560,7 +560,7 @@
560560
}
561561
}
562562

563-
expect { @client.notify(["test1", "test2"], payload) }.to raise_error(Pusher::Error)
563+
expect { @client.notify([], payload) }.to raise_error(Pusher::Error)
564564
end
565565

566566
it "should send a request to the notifications endpoint" do

0 commit comments

Comments
 (0)