Skip to content

Commit

Permalink
Can set email when sending notification with Pushbullet
Browse files Browse the repository at this point in the history
Use configuration key 'notifier.pushbullet.email' to send notification
to this email.
If not set the notification is send to the token owner.
  • Loading branch information
jcgay committed May 21, 2017
1 parent 49bbf6b commit 0510467
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public abstract class PushbulletConfiguration {
@Nullable
public abstract String device();

@Nullable
public abstract String email();

PushbulletConfiguration() {
// prevent external subclasses
}
Expand All @@ -24,7 +27,8 @@ public static PushbulletConfiguration create(Properties properties) {

return new AutoValue_PushbulletConfiguration(
properties.getProperty("notifier.pushbullet.apikey"),
properties.getProperty("notifier.pushbullet.device")
properties.getProperty("notifier.pushbullet.device"),
properties.getProperty("notifier.pushbullet.email")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ private RequestBody buildRequestBody(Notification notification) {
if (configuration.device() != null) {
builder.add("device_iden", configuration.device());
}
if (configuration.email() != null) {
builder.add("email", configuration.email());
}
builder.add("type", "note")
.add("title", notification.title())
.add("body", notification.message());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class PushbulletConfigurationSpec extends Specification {
given:
Properties properties = [
'notifier.pushbullet.apikey':'key',
'notifier.pushbullet.device':'12345'
'notifier.pushbullet.device':'12345',
'notifier.pushbullet.email':'jcgay@does-not-exist.com',
]

when:
Expand All @@ -35,6 +36,7 @@ class PushbulletConfigurationSpec extends Specification {
then:
result.key() == 'key'
result.device() == '12345'
result.email() == 'jcgay@does-not-exist.com'
}

def "should build user configuration without device"() {
Expand All @@ -47,4 +49,15 @@ class PushbulletConfigurationSpec extends Specification {
then:
result.device() == null
}

def "should build user configuration without email"() {
given:
Properties properties = ['notifier.pushbullet.apikey': 'key']

when:
def result = PushbulletConfiguration.create(properties)

then:
result.email() == null
}
}

0 comments on commit 0510467

Please sign in to comment.