Skip to content
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

[Push Notification] Added support for no channels #150

Merged
merged 11 commits into from
Jun 8, 2015

Conversation

fabiomassimo
Copy link
Contributor

Push Notification:

  • If there are no channels (default no channel), the push notification
    is sent to all target devices. (issue #140)
  • Improved support for targeting by platform: a device type is specified as where
    clause
  • Improved support for advanced targeting: if a channel is specified it's also possible to use where clause in it.

## Push Notification:
- If there are no channels (default no channel), the push notification
is sent to all target devices.
- Improved support for targeting by platform: a device type is
specified as [where
clause](https://www.parse.com/docs/push_guide#options-platform/REST)
- Updated test pattern for new “no channel” support compatibility.
- Fixed bug when deviceType and where clause are specified at same time.
@fabiomassimo fabiomassimo mentioned this pull request Nov 9, 2014
@ck3g
Copy link
Contributor

ck3g commented Nov 9, 2014

@fabiomassimo Could you at least use two spaces instead of tabs(or 4 spaces), please? Current indentation are broken.
https://github.com/styleguide/ruby
https://github.com/bbatsov/ruby-style-guide#spaces-indentation

Second. You might broke backward compatibility by replacing default channel from "", to nil. Some people might use it to broadcast messages.

Why are you double checking for !channel?

if !channel
  @where = {} if !channel
else 

- Reverted tabs to soft-spaces as required from [ruby style
guide](https://github.com/styleguide/ruby).
- Reverted channel default value to “”
- Removed superfluous code.
@fabiomassimo
Copy link
Contributor Author

https://github.com/styleguide/ruby
https://github.com/bbatsov/ruby-style-guide#spaces-indentation

Thanks for the great links. This is my first ruby experience. I will definitely look into it.

Second. You might broke backward compatibility by replacing default channel from "", to nil. Some people might use it to broadcast messages.

By using channel=nil in method signature, it only specifies a default value if none has been set, right?
If the user wants to broadcast a message to a channel, when the second parameters is specified it should work. I've reverted it to an empty string anyway.

Why are you double checking for !channel?

Thanks that was a superfluous code.

@ck3g
Copy link
Contributor

ck3g commented Nov 9, 2014

Someone, who is already using a gem, may use push = Parse::Push.new(data) to send to channel ""

@fabiomassimo
Copy link
Contributor Author

I don't think an empty string could be a valid channel.

@ck3g
Copy link
Contributor

ck3g commented Nov 9, 2014

Empty string is a Broadcast channel

@@ -1,45 +1,47 @@
require 'helper'

class TestPush < ParseTestCase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you get rid of trailing whitespaces, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed trailing whitespaces.
Thanks.

Removed trailing superfluous spaces
@@ -15,7 +15,13 @@ class Push

def initialize(data, channel = "")
@data = data
@channel = channel

if channel.empty?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone will set channel as nil explicitly you would get

NoMethodError: undefined method `empty?' for nil:NilClass`

Improved code consistency if `initialize` a push notification with
`nil` channel.
@@ -15,7 +15,13 @@ class Push

def initialize(data, channel = "")
@data = data
@channel = channel

if !channel || channel.empty?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change the default for channel from "" to nil, you can simplify this to if channel.nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if an user initiate a new Push object with: Push.new(data, "")?
The channel parameter is not nil but has the same semantic value of nil.
I used nil as default parameter value in my first commit but than @ck3g pointed out backward compatibility issues like the one I just show you.
What do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, for bc. But if you take backwards compatibility serious, you should not alter the tests, but add new ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tests were inconsistent with Parse REST documentation. That's why I decided to change them.
Previously a simple request with device type set made the test failed because it checked no where clause was created but if you want to specify a device type you have to add it as where clause.
Same goes with nil channel.
If you want to send a broadcast message, you have to add a where clause, hence a simple request could have a where clause and a channel specification.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. And even it's not my responsibility to review your PR, I suggest submitting those changes as separate PR's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitting test pattern changes as different PR will make this PR never pass the Travis check. Or should I ignore it and make a new PR for test pattern changes?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run into that issue from time to time as well.
What if you rebase and merge some of your commits so that you only have 2 left; one with the test pattern changes and one with the other changes. Then you can force push the first commit, let Travis do its thing, and after that push the second commit.
This way it's easier to see what happened and what's the results on Travis per commit.

Changed order check of included parameters in body request to send to
Parse.
@xavdid
Copy link
Collaborator

xavdid commented Jun 3, 2015

@fabiomassimo hey, we can't auto merge this anymore because of other changes. If you'd like to get this in, could you merge master back into your branch and push that?

@rhymes
Copy link
Contributor

rhymes commented Jun 3, 2015

@Xavdidtheshadow not sure what problem this PR solves.

@koenpunt
Copy link

koenpunt commented Jun 4, 2015

@rhymes see #140

@rhymes
Copy link
Contributor

rhymes commented Jun 4, 2015

@koenpunt thanks!

@fabiomassimo
Copy link
Contributor Author

@Xavdidtheshadow thanks for taking care of this pr. Is there anything else I can do to help you out?

@rhymes
Copy link
Contributor

rhymes commented Jun 7, 2015

@fabiomassimo thanks for the fix! You just need to update your branch with the current master and fix the conflicts so that your PR can be merged.

See https://help.github.com/articles/syncing-a-fork/

@fabiomassimo
Copy link
Contributor Author

I just merged the latest changes from current master branch but I didn't come across any merge conflict. Am I missing something?

@xavdid
Copy link
Collaborator

xavdid commented Jun 7, 2015

Did you checkout and git pull each branch before merging?

~DB

On Sun, Jun 7, 2015 at 9:25 AM, Fabio [email protected] wrote:

I just merged the latest changes from current master branch but I didn't come across any merge conflict. Am I missing something?

Reply to this email directly or view it on GitHub:
#150 (comment)

@xavdid
Copy link
Collaborator

xavdid commented Jun 7, 2015

Sorry, wasn't clear. I meant pulled current master and merged that. Sometimes people forget to pull and then merge without conflict. But not that though, huh?

I'm on mobile now, but I can actually dig into what the conflicts are later if you haven't found them by then. 

~DB

On Sun, Jun 7, 2015 at 10:37 AM, Fabio [email protected] wrote:

I merged only from current master branch (main repo).

Why should I merge all branches?

Reply to this email directly or view it on GitHub:
#150 (comment)

@fabiomassimo
Copy link
Contributor Author

@Xavdidtheshadow thanks! I didn't encounter any conflict indeed. Let me know if I'm missing something. It seems good for me..

@xavdid
Copy link
Collaborator

xavdid commented Jun 8, 2015

@fabiomassimo nice, the conflict seems to have resolved itself. Merged!

xavdid added a commit that referenced this pull request Jun 8, 2015
[Push Notification] Added support for no channels
@xavdid xavdid merged commit 6898d6b into adelevie:master Jun 8, 2015
@rhymes
Copy link
Contributor

rhymes commented Jun 8, 2015

@Xavdidtheshadow just a thought, with my push and this we should probably start improving the documentation because they are both changes that modify the behavior

@xavdid
Copy link
Collaborator

xavdid commented Jun 8, 2015

@rhymes totally agree. Do you mind adding relevant documentation as part of #167?

@rhymes
Copy link
Contributor

rhymes commented Jun 8, 2015

@Xavdidtheshadow done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants