Merge remote-tracking branch 'upstream/master'

Conflicts:
	README.md
This commit is contained in:
Frank Klaassen 2014-01-22 20:06:04 +01:00
commit f94083d669
2 changed files with 21 additions and 2 deletions

View File

@ -235,7 +235,7 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or
When using Pushover, this option allows you to specify a single device name to send
notifications to; if blank or unset, notifications will be sent to all devices.
This option must be set when using PushBullet and Airgram.
This option must be set when using PushBullet and Airgram. This module supports both `device_id` (older, numeric id) and the `device_iden` (newer, alphanumeric id) used by PushBullet. You can find your `device_iden` by navigating to a device page and noting the last part of the URL.
### Notifications

View File

@ -196,6 +196,18 @@ class CPushMod : public CModule
return result;
}
/**
* Verifies whether a given string contains only numbers.
*
* @param content String to verify
*/
bool is_number(const CString& content)
{
CString::const_iterator it = content.begin();
while(it != content.end() && std::isdigit(*it)) ++it;
return !content.empty() && it == content.end();
}
/**
* Send a message to the currently-configured push service.
* Requires (and assumes) that the user has already configured their
@ -267,7 +279,14 @@ class CPushMod : public CModule
service_auth = options["secret"] + CString(":");
service_auth.Base64Encode();
// Pushbullet uses numeric device_id but they
// are transitioning to an alphanumeric device_iden
if (is_number(options["target"]))
{
params["device_id"] = options["target"];
} else {
params["device_iden"] = options["target"];
}
params["type"] = "note";
params["title"] = message_title;
params["body"] = message_content;