7: Make JupiterPerpsAlarm send the note on the push notification
This commit is contained in:
@@ -20,18 +20,8 @@ public final class PushoverAlarmAction implements AlarmAction {
|
|||||||
@Override
|
@Override
|
||||||
public void trigger(OraclePrice price, PriceAlarmDefinition alarm) {
|
public void trigger(OraclePrice price, PriceAlarmDefinition alarm) {
|
||||||
String title = "Jupiter Perps " + price.asset() + " alarm";
|
String title = "Jupiter Perps " + price.asset() + " alarm";
|
||||||
String message = String.format(
|
String message = createMessage(price, alarm);
|
||||||
"%s is %s USD. Target: %s %s USD. Oracle time: %s. Slot: %d.",
|
|
||||||
price.asset(),
|
|
||||||
price.priceUsd().toPlainString(),
|
|
||||||
alarm.direction(),
|
|
||||||
alarm.target().toPlainString(),
|
|
||||||
price.oracleTime(),
|
|
||||||
price.slot()
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: Note is intentionally parsed and retained in the model, but are not used by Pushover yet.
|
|
||||||
// https://git.r35157.com/r35157/com_r35157_nenjim-hubd-impl_ref/issues/7
|
|
||||||
String body = form("token", applicationToken) + "&" +
|
String body = form("token", applicationToken) + "&" +
|
||||||
form("user", userKey) + "&" +
|
form("user", userKey) + "&" +
|
||||||
form("title", title) + "&" +
|
form("title", title) + "&" +
|
||||||
@@ -79,6 +69,21 @@ public final class PushoverAlarmAction implements AlarmAction {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String createMessage(OraclePrice price, PriceAlarmDefinition alarm) {
|
||||||
|
return String.format(
|
||||||
|
"%d - %s: %s%n%n%s is %s USD.%nTarget: %s %s USD.%nOracle time: %s.%nSlot: %d.",
|
||||||
|
alarm.id(),
|
||||||
|
alarm.severity(),
|
||||||
|
alarm.note(),
|
||||||
|
price.asset(),
|
||||||
|
price.priceUsd().toPlainString(),
|
||||||
|
alarm.direction(),
|
||||||
|
alarm.target().toPlainString(),
|
||||||
|
price.oracleTime(),
|
||||||
|
price.slot()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private final HttpClient httpClient = HttpClient.newHttpClient();
|
private final HttpClient httpClient = HttpClient.newHttpClient();
|
||||||
private final String applicationToken;
|
private final String applicationToken;
|
||||||
private final String userKey;
|
private final String userKey;
|
||||||
|
|||||||
Reference in New Issue
Block a user