fix: Resolve OTP verification instant transition and ensure bulletproof non-crashing conversation contact listing

This commit is contained in:
Hamza-Ayed
2026-08-27 12:09:09 +03:00
parent 9e9417f937
commit e16ad471c3
3 changed files with 21 additions and 6 deletions
+17 -5
View File
@@ -34,7 +34,11 @@ class ChatController
[$tId]
);
}
} catch (\Throwable $e) {
error_log("Seed teacher note: " . $e->getMessage());
}
try {
// Ensure default sample students if no students exist
$student = Database::selectOne("SELECT id FROM users WHERE role = 'student' LIMIT 1");
if (!$student) {
@@ -55,8 +59,8 @@ class ChatController
);
}
}
} catch (\Exception $e) {
error_log("Seed users note: " . $e->getMessage());
} catch (\Throwable $e) {
error_log("Seed students note: " . $e->getMessage());
}
}
@@ -81,7 +85,7 @@ class ChatController
ORDER BY u.id DESC
LIMIT 100
", [$userId]);
} catch (\Exception $e) {
} catch (\Throwable $e) {
error_log("Users select in getConversations error: " . $e->getMessage());
}
@@ -107,12 +111,20 @@ class ChatController
WHERE sender_id = ? AND receiver_id = ? AND is_read = 0
", [$otherId, $userId]);
$unreadCount = (int)($unreadRow['cnt'] ?? 0);
} catch (\Exception $e) {
} catch (\Throwable $e) {
// Ignore per-user message query issue if any
}
$rawName = (string)($row['encrypted_name'] ?? '');
$decryptedName = Security::decrypt($rawName) ?: $rawName;
$decryptedName = $rawName;
try {
$dec = Security::decrypt($rawName);
if (!empty($dec)) {
$decryptedName = $dec;
}
} catch (\Throwable $e) {
$decryptedName = $rawName;
}
$conversations[] = [
'user_id' => $otherId,