Skip to content

Commit 0510467

Browse files
committed
Can set email when sending notification with Pushbullet
Use configuration key 'notifier.pushbullet.email' to send notification to this email. If not set the notification is send to the token owner.
1 parent 49bbf6b commit 0510467

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

send-notification/src/main/java/fr/jcgay/notification/notifier/pushbullet/PushbulletConfiguration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public abstract class PushbulletConfiguration {
1515
@Nullable
1616
public abstract String device();
1717

18+
@Nullable
19+
public abstract String email();
20+
1821
PushbulletConfiguration() {
1922
// prevent external subclasses
2023
}
@@ -24,7 +27,8 @@ public static PushbulletConfiguration create(Properties properties) {
2427

2528
return new AutoValue_PushbulletConfiguration(
2629
properties.getProperty("notifier.pushbullet.apikey"),
27-
properties.getProperty("notifier.pushbullet.device")
30+
properties.getProperty("notifier.pushbullet.device"),
31+
properties.getProperty("notifier.pushbullet.email")
2832
);
2933
}
3034
}

send-notification/src/main/java/fr/jcgay/notification/notifier/pushbullet/PushbulletNotifier.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ private RequestBody buildRequestBody(Notification notification) {
9494
if (configuration.device() != null) {
9595
builder.add("device_iden", configuration.device());
9696
}
97+
if (configuration.email() != null) {
98+
builder.add("email", configuration.email());
99+
}
97100
builder.add("type", "note")
98101
.add("title", notification.title())
99102
.add("body", notification.message());

send-notification/src/test/groovy/fr/jcgay/notification/notifier/pushbullet/PushbulletConfigurationSpec.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class PushbulletConfigurationSpec extends Specification {
2626
given:
2727
Properties properties = [
2828
'notifier.pushbullet.apikey':'key',
29-
'notifier.pushbullet.device':'12345'
29+
'notifier.pushbullet.device':'12345',
30+
'notifier.pushbullet.email':'[email protected]',
3031
]
3132

3233
when:
@@ -35,6 +36,7 @@ class PushbulletConfigurationSpec extends Specification {
3536
then:
3637
result.key() == 'key'
3738
result.device() == '12345'
39+
result.email() == '[email protected]'
3840
}
3941

4042
def "should build user configuration without device"() {
@@ -47,4 +49,15 @@ class PushbulletConfigurationSpec extends Specification {
4749
then:
4850
result.device() == null
4951
}
52+
53+
def "should build user configuration without email"() {
54+
given:
55+
Properties properties = ['notifier.pushbullet.apikey': 'key']
56+
57+
when:
58+
def result = PushbulletConfiguration.create(properties)
59+
60+
then:
61+
result.email() == null
62+
}
5063
}

0 commit comments

Comments
 (0)