lib/pubsub.js
function adjureAnnotations(uris, annotations, username) {
    GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
    try {
      var user = GLOBAL.svc.auth.getUserByUsername(username);
      if (!user) {
        throw new Error("no user " + username);
      }
      uris.forEach(function(uri) {
        var annos = [];
    // TODO apply validation state based on user
        annotations.forEach(function(p) {
          p.roots = p.roots || [username];
          p.annotatedBy = username;
          p.state = utils.states.annotations.unvalidated;
          if (!user.needsValidation) {
            p.state = utils.states.annotations.validated;
          }
          p.hasTarget = uri;
          var a = annoLib.createAnnotation(p);
          annos.push(a);
        });

        contentLib.saveAnnotations(uri, { member: username }, annos, function(err, res, cItem) {
          if (cItem) {
            debounceUpdate(cItem);
          } else {
            utils.passingError('missing cItem');
          }
        });
      });
    } catch (err) {
      GLOBAL.error('saveAnnotations failed', err);
      console.trace();
    }
  }
function adjureAnnotations(uris, annotations, username) {
    GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
    try {
      var user = GLOBAL.svc.auth.getUserByUsername(username);
      if (!user) {
        throw new Error("no user " + username);
      }
      uris.forEach(function(uri) {
        var annos = [];
    // TODO apply validation state based on user
        annotations.forEach(function(p) {
          p.roots = p.roots || [username];
          p.annotatedBy = username;
          p.state = utils.states.annotations.unvalidated;
          if (!user.needsValidation) {
            p.state = utils.states.annotations.validated;
          }
          p.hasTarget = uri;
          var a = annoLib.createAnnotation(p);
          annos.push(a);
        });

        contentLib.saveAnnotations(uri, { member: username }, annos, function(err, res, cItem) {
          if (cItem) {
            debounceUpdate(cItem);
          } else {
            utils.passingError('missing cItem');
          }
        });
      });
    } catch (err) {
      GLOBAL.error('saveAnnotations failed', err);
      console.trace();
    }
  }
function adjureAnnotations ( uris , annotations , username ) { GLOBAL . info ( '/item/annotations/adjure annotations' . yellow , username . blue , uris , annotations . length ) ; try { var user = GLOBAL . svc . auth . getUserByUsername ( username ) ; if ( ! user ) { throw new Error ( "no user " + username ) ; } uris . forEach ( function ( uri ) { var annos = [ ] ; // TODO apply validation state based on user annotations . forEach ( function ( p ) { p . roots = p . roots || [ username ] ; p . annotatedBy = username ; p . state = utils . states . annotations . unvalidated ; if ( ! user . needsValidation ) { p . state = utils . states . annotations . validated ; } p . hasTarget = uri ; var a = annoLib . createAnnotation ( p ) ; annos . push ( a ) ; } ) ; contentLib . saveAnnotations ( uri , { member : username } , annos , function ( err , res , cItem ) { if ( cItem ) { debounceUpdate ( cItem ) ; } else { utils . passingError ( 'missing cItem' ) ; } } ) ; } ) ; } catch ( err ) { GLOBAL . error ( 'saveAnnotations failed' , err ) ; console . trace ( ) ; } }
apply annotations for the uris
apply annotations for the uris