Skip to content

Commit da882bc

Browse files
Omidiora SamuelOmidiora Samuel
Omidiora Samuel
authored and
Omidiora Samuel
committed
updated enable and disable price alert
1 parent 4e5ec23 commit da882bc

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

server/models/alert.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = (Alert) => {
100100

101101
Alert.disable = async function(accessToken, {alertId}=data, cb){
102102
let err = null
103-
if (!access_token || !access_token.userId) {
103+
if (!accessToken || !accessToken.userId) {
104104
const err = new Error('accessToken is required ');
105105
err.status = 401
106106
cb(err, null)
@@ -110,9 +110,9 @@ module.exports = (Alert) => {
110110
let userId = accessToken.userId.toString()
111111
userId = new ObjectID(userId)
112112

113-
let alert = new ObjectID(alertId)
113+
alertId = new ObjectID(alertId)
114114

115-
const result = await Alert.updateAll({userId, alert }, { status: false }).catch(e=>err=e)
115+
const result = await Alert.updateAll({ userId, id: alertId }, { status: false }).catch(e=>err=e)
116116
if(err){
117117
cb(err)
118118
return
@@ -122,7 +122,7 @@ module.exports = (Alert) => {
122122

123123
Alert.enable = async function(accessToken, {alertId}=data, cb){
124124
let err = null
125-
if (!access_token || !access_token.userId) {
125+
if (!accessToken || !accessToken.userId) {
126126
const err = new Error('accessToken is required ');
127127
err.status = 401
128128
cb(err, null)
@@ -132,9 +132,8 @@ module.exports = (Alert) => {
132132
let userId = accessToken.userId.toString()
133133
userId = new ObjectID(userId)
134134

135-
let alert = new ObjectID(alertId)
136-
137-
const result = await Alert.updateAll({userId, alert }, { status: true }).catch(e=>err=e)
135+
alertId = new ObjectID(alertId)
136+
const result = await Alert.updateAll({userId, 'id': alertId }, { status: true }).catch(e=>err=e)
138137
if(err){
139138
cb(err)
140139
return
@@ -295,7 +294,7 @@ module.exports = (Alert) => {
295294

296295
Alert.remoteMethod('disable', {
297296
http: {
298-
path: '/',
297+
path: '/disable',
299298
verb: 'post'
300299
},
301300
accepts: [
@@ -315,7 +314,7 @@ module.exports = (Alert) => {
315314

316315
Alert.remoteMethod('enable', {
317316
http: {
318-
path: '/',
317+
path: '/enable',
319318
verb: 'post'
320319
},
321320
accepts: [
@@ -332,7 +331,7 @@ module.exports = (Alert) => {
332331
description: 'Enable User Alert',
333332
returns: {root: true},
334333
})
335-
334+
336335
Alert.disableRemoteMethodByName('get');
337336
Alert.disableRemoteMethodByName('create');
338337

0 commit comments

Comments
 (0)