notifications: fix update notification

the notification wasn't working because this was in apptask and the apptask died
before it could send out the email. we now move the notification to box process
and also remove the email notification.
This commit is contained in:
Girish Ramakrishnan
2021-04-19 14:22:22 -07:00
parent 3ab0a25ec9
commit 355de5b0a4
8 changed files with 60 additions and 169 deletions

View File

@@ -649,7 +649,7 @@ function scheduleTask(appId, installationState, taskId, callback) {
} else if (!(installationState === exports.ISTATE_PENDING_UNINSTALL && !error)) { // clear out taskId except for successful uninstall
appdb.update(appId, { taskId: null }, callback);
} else {
callback();
callback(null);
}
});
});
@@ -674,7 +674,7 @@ function addTask(appId, installationState, task, callback) {
if (error && error.reason === BoxError.NOT_FOUND) return callback(new BoxError(BoxError.BAD_STATE, 'Another task is scheduled for this app')); // could be because app went away OR a taskId exists
if (error) return callback(error);
if (scheduleNow) scheduleTask(appId, installationState, taskId, NOOP_CALLBACK);
if (scheduleNow) scheduleTask(appId, installationState, taskId, task.onFinished || NOOP_CALLBACK);
callback(null, { taskId });
});
@@ -1374,7 +1374,10 @@ function update(app, data, auditSource, callback) {
const task = {
args: { updateConfig },
values
values,
onFinished: (error) => {
eventlog.add(eventlog.ACTION_APP_UPDATE_FINISH, auditSource, { app, success: !error, errorMessage: error ? error.message : null }, () => {}); // ignore error
}
};
addTask(appId, exports.ISTATE_PENDING_UPDATE, task, function (error, result) {
if (error) return callback(error);