refactor: update OTP system to support user-specific verification tables with legacy encryption and multi-role authentication.

This commit is contained in:
Hamza-Ayed
2026-04-23 17:03:38 +03:00
parent d64a423db9
commit 098aa9ad37
10 changed files with 649 additions and 189 deletions

View File

@@ -28,7 +28,10 @@ class FcmService
}
/**
* Send FCM notification to a specific device token
* Send localized FCM notification using translation keys (Best for multi-language support)
*/
/**
* Send FCM notification to a specific device token (Raw Text)
*/
public function sendToDevice(string $token, string $title, string $body, array $data = [], string $category = ''): array
{
@@ -36,12 +39,10 @@ class FcmService
return ['status' => 'error', 'message' => 'Empty token'];
}
// Add category to data payload
if ($category) {
$data['category'] = $category;
}
// Convert non-string data values
$stringData = [];
foreach ($data as $key => $value) {
$stringData[$key] = is_array($value) ? json_encode($value) : (string) $value;
@@ -72,6 +73,53 @@ class FcmService
return $this->sendRequest($payload);
}
/**
* Send localized FCM notification using translation keys (Best for multi-language support)
*/
public function sendLocalizedToDevice(string $token, string $titleKey, string $bodyKey, array $data = [], string $category = ''): array
{
if (empty($token)) {
return ['status' => 'error', 'message' => 'Empty token'];
}
if ($category) {
$data['category'] = $category;
}
$stringData = [];
foreach ($data as $key => $value) {
$stringData[$key] = is_array($value) ? json_encode($value) : (string) $value;
}
$payload = [
'message' => [
'token' => $token,
'data' => $stringData,
'android' => [
'priority' => 'high',
'notification' => [
'title_loc_key' => $titleKey,
'body_loc_key' => $bodyKey,
],
],
'apns' => [
'payload' => [
'aps' => [
'sound' => 'default',
'badge' => 1,
'alert' => [
'title-loc-key' => $titleKey,
'loc-key' => $bodyKey,
],
],
],
],
],
];
return $this->sendRequest($payload);
}
/**
* Send to FCM topic
*/