- $user = User::getKV('email', common_canonical_email($nore));
-
- if (!$user) {
- try {
- $user = User::getKV('nickname', common_canonical_nickname($nore));
- } catch (NicknameException $e) {
- // invalid
+ // $confirm_email will be used as a fallback if our user doesn't have a confirmed email
+ $confirm_email = null;
+
+ if (common_is_email($nore)) {
+ $user = User::getKV('email', common_canonical_email($nore));
+
+ // See if it's an unconfirmed email address
+ if (!$user instanceof User) {
+ // Warning: it may actually be legit to have multiple folks
+ // who have claimed, but not yet confirmed, the same address.
+ // We'll only send to the first one that comes up.
+ $confirm_email = new Confirm_address();
+ $confirm_email->address = common_canonical_email($nore);
+ $confirm_email->address_type = 'email';
+ if ($confirm_email->find(true)) {
+ $user = User::getKV('id', $confirm_email->user_id);
+ }