function populateUserInfo(user) {
  if (!user)
    return; // Permissions remain at defaults (false)

  let team = this;
  if (this.members && this.members.filter(member => member.id === user.id).length)
    team.userIsMember = true;

  if (team.moderators && team.moderators.filter(moderator => moderator.id === user.id).length)
    team.userIsModerator = true;

  if (user.id === team.createdBy)
    team.userIsFounder = true;

  if (team.userIsMember && (!team.onlyModsCanBlog || team.userIsModerator))
    team.userCanBlog = true;

  // Can't join if you have a pending or rejected join request
  if (!team.userIsMember && !team.joinRequests.filter(request => request.userID === user.id).length)
    team.userCanJoin = true;

  if (team.userIsModerator || user.isSuperUser)
    team.userCanEdit = true;

  // For now, only site-wide mods can delete teams
  if (user.isSuperUser || user.isSiteModerator)
    team.userCanDelete = true;

  // For now, founders can't leave their team - must be deleted
  if (!team.userIsFounder && team.userIsMember)
    team.userCanLeave = true;

}
/**
 * Populate the virtual permission and metadata fields for this team with
 * information for a given user. This includes properties like `userIsMember`
 * and `userIsModerator`.
 *
 * @param {User}
 *  user whose permissions and metadata to use to populate the fields
 * @memberof Team
 * @instance
 */
Populate the virtual permission and metadata fields for this team with
information for a given user. This includes properties like `userIsMember`
and `userIsModerator`.

@param {User}
user whose permissions and metadata to use to populate the fields
@memberof Team
@instance
Populate the virtual permission and metadata fields for this team with information for a given user . This includes properties like ` userIsMember ` and ` userIsModerator ` . @param { User } user whose permissions and metadata to use to populate the fields @memberof Team @instance
function populateUserInfo(user) {
  if (!user)
    return; 
  let team = this;
  if (this.members && this.members.filter(member => member.id === user.id).length)
    team.userIsMember = true;
  if (team.moderators && team.moderators.filter(moderator => moderator.id === user.id).length)
    team.userIsModerator = true;
  if (user.id === team.createdBy)
    team.userIsFounder = true;
  if (team.userIsMember && (!team.onlyModsCanBlog || team.userIsModerator))
    team.userCanBlog = true;
  if (!team.userIsMember && !team.joinRequests.filter(request => request.userID === user.id).length)
    team.userCanJoin = true;
  if (team.userIsModerator || user.isSuperUser)
    team.userCanEdit = true;
  if (user.isSuperUser || user.isSiteModerator)
    team.userCanDelete = true;
  if (!team.userIsFounder && team.userIsMember)
    team.userCanLeave = true;
}
function populateUserInfo ( user ) { if ( ! user ) return ; let team = this ; if ( this . members && this . members . filter ( member => member . id === user . id ) . length ) team . userIsMember = true ; if ( team . moderators && team . moderators . filter ( moderator => moderator . id === user . id ) . length ) team . userIsModerator = true ; if ( user . id === team . createdBy ) team . userIsFounder = true ; if ( team . userIsMember && ( ! team . onlyModsCanBlog || team . userIsModerator ) ) team . userCanBlog = true ; if ( ! team . userIsMember && ! team . joinRequests . filter ( request => request . userID === user . id ) . length ) team . userCanJoin = true ; if ( team . userIsModerator || user . isSuperUser ) team . userCanEdit = true ; if ( user . isSuperUser || user . isSiteModerator ) team . userCanDelete = true ; if ( ! team . userIsFounder && team . userIsMember ) team . userCanLeave = true ; }
Populate the virtual permission and metadata fields for this team with
 information for a given user.
Populate the virtual permission and metadata fields for this team with information for a given user .
// Permissions remain at defaults (false) // Can't join if you have a pending or rejected join request // For now, only site-wide mods can delete teams // For now, founders can't leave their team - must be deleted