Skip to content

Conversation

akilism
Copy link
Contributor

@akilism akilism commented Apr 19, 2014

Hi!

I wrote a little Pushover Agent with tests. Supports these optional api parameters with event level override.

device
title
url
url_title
priority
timestamp
sound

cannot_be_scheduled!
cannot_create_events!

@@api_url = 'https://api.pushover.net/1/messages.json'
Copy link
Member

Choose a reason for hiding this comment

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

Stylistically, this might be better as a constant. E.g., API_URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And I took care of this as well.

@cantino
Copy link
Member

cantino commented Apr 19, 2014

This is great work @akilism, thank you! I left a couple of small comments.

@deanputney
Copy link
Contributor

❤️ I've been wanting this for a while! Thanks!

On Friday, April 18, 2014, Andrew Cantino notifications@github.com wrote:

This is great work @akilism https://github.com/akilism, thank you! I
left a couple of small comments.


Reply to this email directly or view it on GitHubhttps://github.com//pull/233#issuecomment-40861068
.

Dean

end

def validate_options
unless options['token'].present? && options['user'].present? && options['expected_receive_period_in_days'].present?
Copy link
Collaborator

Choose a reason for hiding this comment

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

You provided default values for the token and the user which means if the user does not empty those fields your validation will always pass, i would change the default options for token and user to an empty string.

Personally i am not a big fan of determinating the state of an agent which is receiving events based on the time frame it received the last event. I would rather base it on the (un)successful delivery of the events it received.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I can see that. I'll make this change later today. Really I'd like to take into account the response from pushover as to whether or not the notification was successful, a failure that can be retried or a failure that will never be successful and shouldn't be retried.

@akilism
Copy link
Contributor Author

akilism commented Apr 26, 2014

@cantino any word on this?

@cantino
Copy link
Member

cantino commented Apr 26, 2014

Sorry, I missed this. I'll try to look at it tonight-- traveling today.

}

post_params['device'] = event.payload['device'] || options['device']
post_params['title'] = event.payload['title'] || event.payload['subject'] || options['title']
Copy link
Member

Choose a reason for hiding this comment

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

The only other change I'd suggest is to use .presence on these, so that empty fields are treated as missing.

post_params['title'] = event.payload['title'].presence || event.payload['subject'].presence || options['title']

and also below, anywhere you think that makes sense. E.g,

url = (event.payload['url'].presence || options['url'] || '').to_s

url_title = (event.payload['url_title'].presence || options['url_title']).to_s

post_params['priority'] = (event.payload['priority'].presence || options['priority']).to_i

etc.

sound, retry, expire, ...

Anything where empty string should be treated as nil.

@akilism
Copy link
Contributor Author

akilism commented Apr 28, 2014

Got it. I'll make this changes tonight!

@akilism
Copy link
Contributor Author

akilism commented Apr 29, 2014

@cantino Updated.

cantino added a commit that referenced this pull request Apr 29, 2014
@cantino cantino merged commit 764b4bd into huginn:master Apr 29, 2014
@cantino
Copy link
Member

cantino commented Apr 29, 2014

Thanks @akilism, nice work!

@akilism akilism deleted the pushover branch April 29, 2014 03:16
DataMinerUK pushed a commit to DataMinerUK/huginn that referenced this pull request Oct 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants