Notify alerts

pull/146/head
M66B 7 years ago
parent 6ea74b20b1
commit a749e155aa

@ -714,7 +714,7 @@ public class ServiceSynchronize extends LifecycleService {
EntityLog.log(this, action + " " + Helper.formatThrowable(ex)); EntityLog.log(this, action + " " + Helper.formatThrowable(ex));
if (ex instanceof SendFailedException) { if ((ex instanceof SendFailedException) || (ex instanceof AlertException)) {
NotificationManager nm = getSystemService(NotificationManager.class); NotificationManager nm = getSystemService(NotificationManager.class);
nm.notify(action, 1, getNotificationError(action, ex).build()); nm.notify(action, 1, getNotificationError(action, ex).build());
} }
@ -779,6 +779,7 @@ public class ServiceSynchronize extends LifecycleService {
EntityLog.log(ServiceSynchronize.this, account.name + " " + type + ": " + e.getMessage()); EntityLog.log(ServiceSynchronize.this, account.name + " " + type + ": " + e.getMessage());
if (e.getMessageType() == StoreEvent.ALERT) { if (e.getMessageType() == StoreEvent.ALERT) {
db.account().setAccountError(account.id, e.getMessage()); db.account().setAccountError(account.id, e.getMessage());
reportError(account.name, null, new AlertException(e.getMessage()));
state.error(); state.error();
} }
} finally { } finally {
@ -2696,4 +2697,17 @@ public class ServiceSynchronize extends LifecycleService {
return "[running=" + running + "]"; return "[running=" + running + "]";
} }
} }
private class AlertException extends Throwable {
private String alert;
AlertException(String alert) {
this.alert = alert;
}
@Override
public String getMessage() {
return alert;
}
}
} }

Loading…
Cancel
Save