code: def claim_invitations(user):
      
      # See if there are any build invitations present for the user with this
      # email address. If so, replace all those invitations with the real user.
      invitation_user_id = '%s:%s' % (
          models.User.EMAIL_INVITATION, user.email_address)
      invitation_user = models.User.query.get(invitation_user_id)
      if invitation_user:
          invited_build_list = list(invitation_user.builds)
          if not invited_build_list:
              return
  
          db.session.add(user)
          logging.debug('Found %d build admin invitations for id=%r, user=%r',
                        len(invited_build_list), invitation_user_id, user)
  
          for build in invited_build_list:
              build.owners.remove(invitation_user)
              if not build.is_owned_by(user.id):
                  build.owners.append(user)
                  logging.debug('Claiming invitation for build_id=%r', build.id)
                  save_admin_log(build, invite_accepted=True)
              else:
                  logging.debug('User already owner of build. '
                                'id=%r, build_id=%r', user.id, build.id)
              db.session.add(build)
  
          db.session.delete(invitation_user)
          db.session.commit()
          # Re-add the user to the current session so we can query with it.
          db.session.add(current_user)
docs: Claims any pending invitations for the given user's email address.