vicinityManager/server/services/sharingRules.js
/*
Find how to resolve the accessLevel change in the device
Based on old and new accessLevel captions
*/
Find how to resolve the accessLevel change in the device
Based on old and new accessLevel captions
Find how to resolve the accessLevel change in the device Based on old and new accessLevel captions
function findCase(oldA, newA, updates, callback){
  var id = updates.id || updates.o_id;
  var item = {};
  if((oldA === 2 && newA === 1) || (oldA === 2 && newA === 0) || (oldA === 1 && newA === 0)) {
    itemOp.findOne({_id: id},{hasContracts:1, oid:1, cid:1, accessLevel:1, typeOfItem:1}).populate('cid.id', 'knows')
    .then( function(response){
      item = response.toObject();
      item.accessLevel = newA;
      return ctHelper.removeDevice(item, {}, function(value, result){
        callback(false, result);
      });
    })
    .catch(function(err){
      logger.debug(err);
      callback(true, err);
    });
  } else {
    logger.debug("No action required!");
    callback(false, 'Nothing');
  }
}
function findCase ( oldA , newA , updates , callback ) { var id = updates . id || updates . o_id ; var item = { } ; if ( ( oldA === 2 && newA === 1 ) || ( oldA === 2 && newA === 0 ) || ( oldA === 1 && newA === 0 ) ) { itemOp . findOne ( { _id : id } , { hasContracts : 1 , oid : 1 , cid : 1 , accessLevel : 1 , typeOfItem : 1 } ) . populate ( 'cid.id' , 'knows' ) . then ( function ( response ) { item = response . toObject ( ) ; item . accessLevel = newA ; return ctHelper . removeDevice ( item , { } , function ( value , result ) { callback ( false , result ) ; } ) ; } ) . catch ( function ( err ) { logger . debug ( err ) ; callback ( true , err ) ; } ) ; } else { logger . debug ( "No action required!" ) ; callback ( false , 'Nothing' ) ; } }
Find how to resolve the accessLevel change in the device
Based on old and new accessLevel captions
Find how to resolve the accessLevel change in the device Based on old and new accessLevel captions