// NewInviteeInfoWithPermissionLevel returns a new InviteeInfoWithPermissionLevel instance
335879
func NewInviteeInfoWithPermissionLevel(Invitee *sharing.InviteeInfo, PermissionLevel *PaperDocPermissionLevel) *InviteeInfoWithPermissionLevel {
	s := new(InviteeInfoWithPermissionLevel)
	s.Invitee = Invitee
	s.PermissionLevel = PermissionLevel
	return s
}
482077
func NewPaperDocTeamInviteType(Description string) *PaperDocTeamInviteType {
	s := new(PaperDocTeamInviteType)
	s.Description = Description
	return s
}
846765
func (o *InvitationManager) HasInvite(globalid string, username string) (hasInvite bool, err error) {
	count, err := o.collection.Find(bson.M{"organization": globalid, "user": username}).Count()
	return count != 0, err
}
403175
func NewSfFbInviteChangeRoleDetails(TargetAssetIndex uint64, OriginalFolderName string) *SfFbInviteChangeRoleDetails {
	s := new(SfFbInviteChangeRoleDetails)
	s.TargetAssetIndex = TargetAssetIndex
	s.OriginalFolderName = OriginalFolderName
	return s
}
1223032
func NewSharedContentAddInviteesType(Description string) *SharedContentAddInviteesType {
	s := new(SharedContentAddInviteesType)
	s.Description = Description
	return s
}
977554
func (api *API) OrganizationInvites(organizationID string) ([]OrganizationInvite, ResultInfo, error) {
	var r organizationInvitesResponse
	uri := "/organizations/" + organizationID + "/invites"
	res, err := api.makeRequest("GET", uri, nil)
	if err != nil {
		return []OrganizationInvite{}, ResultInfo{}, errors.Wrap(err, errMakeRequestError)
	}

	err = json.Unmarshal(res, &r)
	if err != nil {
		return []OrganizationInvite{}, ResultInfo{}, errors.Wrap(err, errUnmarshalError)
	}

	return r.Result, r.ResultInfo, nil
}
119569
func NewUserMembershipInfo(AccessType *AccessLevel, User *UserInfo) *UserMembershipInfo {
	s := new(UserMembershipInfo)
	s.AccessType = AccessType
	s.User = User
	s.IsInherited = false
	return s
}
59469
func (c *InvitationController) CreateInvite(ctx *app.CreateInviteInvitationContext) error {
	currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	var redirectOnSuccess, redirectOnFailure string
	links := ctx.Payload.Links
	if links != nil {
		if links.OnSuccess != nil {
			redirectOnSuccess = *links.OnSuccess
		}
		if links.OnFailure != nil {
			redirectOnFailure = *links.OnFailure
		}
	}

	var invitations []invitation.Invitation

	for _, invitee := range ctx.Payload.Data {
		// Validate that an identifying parameter has been set
		if invitee.IdentityID == nil {
			return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterErrorFromString("user identifier", "", "no identifier provided"))
		}

		// If an identity ID has been provided for the user, convert it to a UUID here
		var identityID uuid.UUID
		if invitee.IdentityID != nil && *invitee.IdentityID != "" {
			identityID, err = uuid.FromString(*invitee.IdentityID)
		}

		// Create the Invitation object, and append it to our list of invitations
		invitations = append(invitations, invitation.Invitation{
			IdentityID:        &identityID,
			Roles:             invitee.Roles,
			Member:            *invitee.Member,
			RedirectOnSuccess: redirectOnSuccess,
			RedirectOnFailure: redirectOnFailure,
		})
	}

	err = c.app.InvitationService().Issue(ctx, currentIdentity.ID, ctx.InviteTo, invitations)

	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err,
		}, "failed to create invitations")

		return jsonapi.JSONErrorResponse(ctx, err)
	}

	log.Debug(ctx, map[string]interface{}{
		"issuing-user-id": *currentIdentity,
		"invite-to":       ctx.InviteTo,
	}, "invitations created")

	return ctx.Created()
}
680232
func NewNodeInfoManager(
	nodeName types.NodeName,
	volumeHost volume.VolumeHost,
	migratedPlugins map[string](func() bool)) Interface {
	return &nodeInfoManager{
		nodeName:        nodeName,
		volumeHost:      volumeHost,
		migratedPlugins: migratedPlugins,
	}
}
1227083
func NewWithRedisConf(dbindex int, hostPort string) *Permissions {
	return NewPermissions(NewUserState(dbindex, true, hostPort))
}
1108155
func (api OrganizationsAPI) autoAcceptSubOrgInvite(invite *invitations.JoinOrganizationInvitation, mgr *organization.Manager) (bool, error) {
	globalid := invite.Organization

	// If this is an invite for a root organization we obviously aren't a member of a parent yet
	if !strings.Contains(globalid, ".") {
		return false, nil
	}

	// Check for username so we only auto accept already registered users
	// Not sure if this is needed but it doesn't hurt to check
	username := invite.User
	if username == "" {
		log.Debug("can't auto accept the invite because the username is not known")
		return false, nil
	}

	// Check if we happen to be a member or owner of a parent org
	orgs, err := mgr.AllByUser(username)
	if err != nil {
		return false, err
	}
	inParent := false
	for _, org := range orgs {
		// adding the  "." is required here.
		if strings.HasPrefix(globalid, org.Globalid+".") {
			inParent = true
			break
		}
	}

	if !inParent {
		return false, nil
	}

	// add the user
	org, err := mgr.GetByName(invite.Organization)
	if err != nil {
		return false, err
	}
	if invitations.RoleOwner == invite.Role {
		// Accepted Owner role
		if err := mgr.SaveOwner(org, username); err != nil {
			return false, err
		}
	} else {
		// Accepted member role
		if err := mgr.SaveMember(org, username); err != nil {
			return false, err
		}
	}
	// set the invite to status accpeted
	invite.Status = invitations.RequestAccepted
	log.Debug("Invitation auto accepted because the user is already an owner or member of a parent organization")
	return true, nil
}
500955
func (service *IYOPhonenumberValidationService) SendOrganizationInviteSms(request *http.Request, invite *invitations.JoinOrganizationInvitation) (err error) {
	link := fmt.Sprintf(invitations.InviteURL, request.Host, url.QueryEscape(invite.Code))
	// todo: perhaps this should be shorter but that might be confusing for the end user
	message := fmt.Sprintf("You have been invited to the %s organization on It's You Online. Click the following link to accept it. %s", invite.Organization, link)
	go service.SMSService.Send(invite.PhoneNumber, message)
	return
}
831396
func (o *NSGateway) CreatePermission(child *Permission) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
660777
func (s *Session) GuildInvites(guildID string) (st []*Invite, err error) {
	body, err := s.RequestWithBucketID("GET", EndpointGuildInvites(guildID), nil, EndpointGuildInvites(guildID))
	if err != nil {
		return
	}

	err = unmarshal(body, &st)
	return
}
1039964
func (s *OrganizationsService) RejectOrganizationInvite(invitingorg, role, globalid string, headers, queryParams map[string]interface{}) (*http.Response, error) {
	var err error

	resp, err := s.client.doReqNoBody("DELETE", s.client.BaseURI+"/organizations/"+globalid+"/organizations/"+invitingorg+"/roles/"+role, headers, queryParams)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	return resp, err
}
224946
func NewSfFbInviteDetails(TargetAssetIndex uint64, OriginalFolderName string) *SfFbInviteDetails {
	s := new(SfFbInviteDetails)
	s.TargetAssetIndex = TargetAssetIndex
	s.OriginalFolderName = OriginalFolderName
	return s
}
868741
func NewDomainInvitesApproveRequestToJoinTeamType(Description string) *DomainInvitesApproveRequestToJoinTeamType {
	s := new(DomainInvitesApproveRequestToJoinTeamType)
	s.Description = Description
	return s
}