Deploy: 2026-05-23 01:13:51
This commit is contained in:
@@ -32,6 +32,42 @@ class WhatsAppSession extends BaseModel
|
||||
return $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find secure session by ID
|
||||
*/
|
||||
public static function findSecure(int $id)
|
||||
{
|
||||
$session = Database::selectOne(
|
||||
"SELECT * FROM " . static::$table . " WHERE id = ? LIMIT 1",
|
||||
[$id]
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all WhatsApp sessions for a company
|
||||
*/
|
||||
public static function findAllByCompany(int $companyId): array
|
||||
{
|
||||
$sessions = Database::select(
|
||||
"SELECT * FROM " . static::$table . " WHERE company_id = ? ORDER BY id ASC",
|
||||
[$companyId]
|
||||
);
|
||||
|
||||
foreach ($sessions as &$session) {
|
||||
$session['phone'] = $session['phone'] ? Security::decrypt($session['phone']) : null;
|
||||
$session['qr_code'] = $session['qr_code'] ? Security::decrypt($session['qr_code']) : null;
|
||||
}
|
||||
|
||||
return $sessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a session by session_key (used by webhooks)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user