Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
kresusapp
kresus
Commits
905202ca
Commit
905202ca
authored
Oct 03, 2018
by
Antoine
Committed by
Antoine
Nov 04, 2018
Browse files
Migrate Alert.byAccountAndType to new User API
parent
4e886612
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/lib/alert-manager.js
View file @
905202ca
...
...
@@ -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
;
}
...
...
server/models/alert.js
View file @
905202ca
...
...
@@ -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
'
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment