@@ -100,7 +100,7 @@ module.exports = (Alert) => {
100
100
101
101
Alert . disable = async function ( accessToken , { alertId} = data , cb ) {
102
102
let err = null
103
- if ( ! access_token || ! access_token . userId ) {
103
+ if ( ! accessToken || ! accessToken . userId ) {
104
104
const err = new Error ( 'accessToken is required ' ) ;
105
105
err . status = 401
106
106
cb ( err , null )
@@ -110,9 +110,9 @@ module.exports = (Alert) => {
110
110
let userId = accessToken . userId . toString ( )
111
111
userId = new ObjectID ( userId )
112
112
113
- let alert = new ObjectID ( alertId )
113
+ alertId = new ObjectID ( alertId )
114
114
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 )
116
116
if ( err ) {
117
117
cb ( err )
118
118
return
@@ -122,7 +122,7 @@ module.exports = (Alert) => {
122
122
123
123
Alert . enable = async function ( accessToken , { alertId} = data , cb ) {
124
124
let err = null
125
- if ( ! access_token || ! access_token . userId ) {
125
+ if ( ! accessToken || ! accessToken . userId ) {
126
126
const err = new Error ( 'accessToken is required ' ) ;
127
127
err . status = 401
128
128
cb ( err , null )
@@ -132,9 +132,8 @@ module.exports = (Alert) => {
132
132
let userId = accessToken . userId . toString ( )
133
133
userId = new ObjectID ( userId )
134
134
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 )
138
137
if ( err ) {
139
138
cb ( err )
140
139
return
@@ -295,7 +294,7 @@ module.exports = (Alert) => {
295
294
296
295
Alert . remoteMethod ( 'disable' , {
297
296
http : {
298
- path : '/' ,
297
+ path : '/disable ' ,
299
298
verb : 'post'
300
299
} ,
301
300
accepts : [
@@ -315,7 +314,7 @@ module.exports = (Alert) => {
315
314
316
315
Alert . remoteMethod ( 'enable' , {
317
316
http : {
318
- path : '/' ,
317
+ path : '/enable ' ,
319
318
verb : 'post'
320
319
} ,
321
320
accepts : [
@@ -332,7 +331,7 @@ module.exports = (Alert) => {
332
331
description : 'Enable User Alert' ,
333
332
returns : { root : true } ,
334
333
} )
335
-
334
+
336
335
Alert . disableRemoteMethodByName ( 'get' ) ;
337
336
Alert . disableRemoteMethodByName ( 'create' ) ;
338
337
0 commit comments