Commit 905202ca authored by Antoine's avatar Antoine Committed by Antoine
Browse files

Migrate Alert.byAccountAndType to new User API

parent 4e886612
......@@ -56,7 +56,11 @@ ${$t('server.email.signature')}
// Memoize alerts by account
let alerts;
if (!alertsByAccount.has(operation.accountId)) {
alerts = await Alert.byAccountAndType(operation.accountId, 'transaction');
alerts = await Alert.byAccountAndType(
userId,
operation.accountId,
'transaction'
);
alertsByAccount.set(operation.accountId, alerts);
} else {
alerts = alertsByAccount.get(operation.accountId);
......@@ -93,7 +97,7 @@ ${$t('server.email.signature')}
let accounts = await Account.byAccess(userId, access);
for (let account of accounts) {
let alerts = await Alert.byAccountAndType(account.id, 'balance');
let alerts = await Alert.byAccountAndType(userId, account.id, 'balance');
if (!alerts) {
continue;
}
......
......@@ -43,7 +43,9 @@ Alert = promisifyModel(Alert);
let request = promisify(Alert.request.bind(Alert));
let requestDestroy = promisify(Alert.requestDestroy.bind(Alert));
Alert.byAccountAndType = async function byAccountAndType(accountID, type) {
Alert.byAccountAndType = async function byAccountAndType(userId, accountID, type) {
assert(userId === 0, 'Alert.byAccountAndType first arg must be the userId.');
if (typeof accountID !== 'string') {
log.warn('Alert.byAccountAndType misuse: accountID must be a string');
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment