Deploy: 2026-05-23 03:23:22

This commit is contained in:
Hamza-Ayed
2026-05-23 03:23:22 +03:00
parent 30301151c3
commit d686f8928b
10 changed files with 463 additions and 24 deletions

View File

@@ -86,6 +86,25 @@ class WhatsAppSession extends BaseModel
return $session;
}
/**
* Find session by phone number (useful to prevent duplicates across companies)
*/
public static function findByPhone(string $phone)
{
$phoneHash = Security::blindIndex($phone);
$session = Database::selectOne(
"SELECT * FROM " . static::$table . " WHERE phone_hash = ? LIMIT 1",
[$phoneHash]
);
if ($session) {
$session['phone'] = $session['phone'] ? Security::decrypt($session['phone']) : null;
$session['qr_code'] = $session['qr_code'] ? Security::decrypt($session['qr_code']) : null;
}
return $session;
}
/**
* Create or retrieve a new session for a company
*/