// HasPhoneInvite Checks if a phonenumber has an invite to an organization
186582
func (o *InvitationManager) HasPhoneInvite(globalid string, phonenumber string) (hasInvite bool, err error) {
	count, err := o.collection.Find(bson.M{"organization": globalid, "phonenumber": phonenumber}).Count()
	return count != 0, err
}
479377
func (s *Contact) SetPhoneNumber(v string) *Contact {
	s.PhoneNumber = &v
	return s
}
963000
func (u *User) HasDeviceInCurrentInstall(did keybase1.DeviceID) bool {
	ckf := u.GetComputedKeyFamily()
	if ckf == nil {
		return false
	}

	_, err := ckf.GetSibkeyForDevice(did)
	if err != nil {
		return false
	}
	return true
}
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
}
1105124
func (o *InvitationManager) Get(username string, organization string, role string, status InvitationStatus) (*JoinOrganizationInvitation, error) {
	var orgRequest JoinOrganizationInvitation

	query := bson.M{
		"user":         username,
		"role":         role,
		"organization": organization,
		"status":       status,
	}

	err := o.collection.Find(query).One(&orgRequest)
	if err == mgo.ErrNotFound {
		return nil, nil
	}

	return &orgRequest, err
}
1328595
func (api OrganizationsAPI) AcceptOrganizationInvite(w http.ResponseWriter, r *http.Request) {
	invitedorgname := mux.Vars(r)["globalid"]
	role := mux.Vars(r)["role"]
	invitingorgname := mux.Vars(r)["invitingorg"]

	var j invitations.JoinOrganizationInvitation

	if err := json.NewDecoder(r.Body).Decode(&j); err != nil {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	orgReqMgr := invitations.NewInvitationManager(r)
	orgMgr := organization.NewManager(r)

	if !orgMgr.Exists(invitedorgname) {
		http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
		return
	}

	invitingorg, err := orgMgr.GetByName(invitingorgname)
	if err != nil {
		http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
		return
	}

	orgRequest, err := orgReqMgr.Get(invitedorgname, invitingorgname, role, invitations.RequestPending)
	if err != nil {
		log.Error("error while trying to get invitation for organization")
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if orgRequest == nil {
		http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
		return
	}

	if orgRequest.Role == invitations.RoleOrgOwner {
		if err := orgMgr.SaveOrgOwner(invitingorg, invitedorgname); err != nil {
			log.Error("Failed to save organization owner: ", invitedorgname)
			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
			return
		}
	} else {
		if err := orgMgr.SaveOrgMember(invitingorg, invitedorgname); err != nil {
			log.Error("Failed to save organization member: ", invitedorgname)
			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
			return
		}
	}

	orgRequest.Status = invitations.RequestAccepted

	if err := orgReqMgr.Save(orgRequest); err != nil {
		log.Error("Failed to update org request status: ", orgRequest.Organization)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-type", "application/json")
	w.WriteHeader(http.StatusCreated)

	json.NewEncoder(w).Encode(orgRequest)
}
318975
func (s *OrganizationsService) ListPendingOrgInvitations(ctx context.Context, org string, opt *ListOptions) ([]*Invitation, *Response, error) {
	u := fmt.Sprintf("orgs/%v/invitations", org)
	u, err := addOptions(u, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var pendingInvitations []*Invitation
	resp, err := s.client.Do(ctx, req, &pendingInvitations)
	if err != nil {
		return nil, resp, err
	}
	return pendingInvitations, resp, nil
}
922611
func (c *InvitationController) RescindInvite(ctx *app.RescindInviteInvitationContext) error {
	currentIdentity, err := c.app.UserService().LoadContextIdentityIfNotBanned(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	invitationID, err := uuid.FromString(ctx.InviteTo)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err":          err,
			"invitationID": invitationID,
		}, "failed to rescind invitation, invalid invitation id")

		return jsonapi.JSONErrorResponse(ctx, errors.NewNotFoundError("invitationID", invitationID.String()))
	}

	err = c.app.InvitationService().Rescind(ctx, currentIdentity.ID, invitationID)

	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err":          err,
			"invitationID": invitationID,
		}, "failed to rescind invitation")
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	log.Debug(ctx, map[string]interface{}{
		"rescinding-user-id": *currentIdentity,
		"invitation-id":      ctx.InviteTo,
	}, "invitation rescind")

	return ctx.OK([]byte{})
}
1206223
func (r User_Customer_External_Binding_Phone) RequestPhoneValidation(phoneData *datatypes.Container_User_Data_Phone) (resp string, err error) {
	params := []interface{}{
		phoneData,
	}
	err = r.Session.DoRequest("SoftLayer_User_Customer_External_Binding_Phone", "requestPhoneValidation", params, &r.Options, &resp)
	return
}
335879
func NewInviteeInfoWithPermissionLevel(Invitee *sharing.InviteeInfo, PermissionLevel *PaperDocPermissionLevel) *InviteeInfoWithPermissionLevel {
	s := new(InviteeInfoWithPermissionLevel)
	s.Invitee = Invitee
	s.PermissionLevel = PermissionLevel
	return s
}
138922
func (s *Session) ChannelInvites(channelID string) (st []*Invite, err error) {

	body, err := s.RequestWithBucketID("GET", EndpointChannelInvites(channelID), nil, EndpointChannelInvites(channelID))
	if err != nil {
		return
	}

	err = unmarshal(body, &st)
	return
}
1145288
func (api *Client) CreatePhoneNumber(data *CreatePhoneNumberData) (string, error) {
	_, headers, err := api.makeRequest(http.MethodPost, api.concatUserPath(phoneNumbersPath), nil, data)
	if err != nil {
		return "", err
	}
	return getIDFromLocationHeader(headers), nil
}
684748
func (cli *Client) InviteUserByThirdParty(roomID string, req *ReqInvite3PID) (resp *RespInviteUser, err error) {
	u := cli.BuildURL("rooms", roomID, "invite")
	_, err = cli.MakeRequest("POST", u, req, &resp)
	return
}
799029
func (mr *MockAuthorizerMockRecorder) HasPermission(arg0, arg1 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasPermission", reflect.TypeOf((*MockAuthorizer)(nil).HasPermission), arg0, arg1)
}
597334
func (c *InvitesClient) Get(ctx context.Context, token string) (*PublicInvite, error) {
	p := fmt.Sprintf("/invites/%s/", token)

	req, err := c.backend.NewRequest(http.MethodGet, p, nil, nil)
	if err != nil {
		return nil, err
	}

	var resp PublicInvite
	_, err = c.backend.Do(ctx, req, &resp, func(code int) error {
		return &Error{}
	})
	if err != nil {
		return nil, err
	}

	return &resp, nil
}
1591
func (o *InvitationManager) CountByOrganization(globalid string) (int, error) {
	count, err := o.collection.Find(bson.M{"organization": globalid}).Count()
	return count, err
}
178462
func (api *Client) UpdatePhoneNumber(idOrNumber string, data *UpdatePhoneNumberData) error {
	_, _, err := api.makeRequest(http.MethodPost, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), url.QueryEscape(idOrNumber)), nil, data)
	return err
}