cont3xt/linkGroup.js
/**
   * GET - /api/linkGroup
   *
   * Returns link groups that the requesting user is allowed to view.
   * @name /linkGroup
   * @returns {LinkGroup[]} linkGroups - An array of link groups that the logged in user can view
   * @returns {boolean} success - True if the request was successful, false otherwise
   */
/api/linkGroup
Returns link groups that the requesting user is allowed to view.
@name /linkGroup
@returns {LinkGroup[]} linkGroups - An array of link groups that the logged in user can view
@returns {boolean} success - True if the request was successful, false otherwise
/ api / linkGroup Returns link groups that the requesting user is allowed to view . @name / linkGroup @returns { LinkGroup [] } linkGroups - An array of link groups that the logged in user can view @returns { boolean } success - True if the request was successful false otherwise
static async apiGet (req, res, next) {
    const roles = await req.user.getRoles();
    let linkGroups = await Db.getMatchingLinkGroups(req.user.userId, [...roles]);
    for (const lg of linkGroups) {
      lg._editable = lg.creator === req.user.userId || req.user.hasRole(lg.editRoles);
      lg._viewable = lg.creator === req.user.userId || req.user.hasRole(lg.viewRoles);
    }
    const reordered = [];
    const unordered = [];
    const settings = req.user.cont3xt ?? {};
    if (settings.linkGroup && settings.linkGroup.order) {
      for (const group of linkGroups) {
        if (settings.linkGroup.order.indexOf(group._id) === -1) {
          unordered.push(group);
        }
      }
      for (const id of settings.linkGroup.order) {
        for (const group of linkGroups) {
          if (group._id === id) {
            reordered.push(group);
          }
        }
      }
    }
    if (reordered.length) {
      linkGroups = reordered.concat(unordered);
    }
    res.send({ success: true, linkGroups: linkGroups });
  }
static async apiGet ( req , res , next ) { const roles = await req . user . getRoles ( ) ; let linkGroups = await Db . getMatchingLinkGroups ( req . user . userId , [ ... roles ] ) ; for ( const lg of linkGroups ) { lg . _editable = lg . creator === req . user . userId || req . user . hasRole ( lg . editRoles ) ; lg . _viewable = lg . creator === req . user . userId || req . user . hasRole ( lg . viewRoles ) ; } const reordered = [ ] ; const unordered = [ ] ; const settings = req . user . cont3xt ?? { } ; if ( settings . linkGroup && settings . linkGroup . order ) { for ( const group of linkGroups ) { if ( settings . linkGroup . order . indexOf ( group . _id ) === - 1 ) { unordered . push ( group ) ; } } for ( const id of settings . linkGroup . order ) { for ( const group of linkGroups ) { if ( group . _id === id ) { reordered . push ( group ) ; } } } } if ( reordered . length ) { linkGroups = reordered . concat ( unordered ) ; } res . send ( { success : true , linkGroups : linkGroups } ) ; }
GET - /api/linkGroup
 Returns link groups that the requesting user is allowed to view.
GET - / api / linkGroup Returns link groups that the requesting user is allowed to view .
// Set editable on any linkGroups that the user is allowed to edit