mirror of
https://github.com/appwrite/appwrite
synced 2026-05-16 05:28:31 +00:00
getCountryCode
This commit is contained in:
parent
17b9f136f1
commit
88e67c8d58
2 changed files with 555 additions and 204 deletions
734
composer.lock
generated
734
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -441,31 +441,24 @@ class Messaging extends Action
|
|||
try {
|
||||
$adapter->send($data);
|
||||
|
||||
$countryCode = $sms->getCountryCode($payload['recipient']);
|
||||
|
||||
if (!empty($countryCode)) {
|
||||
$queueForUsage
|
||||
->addMetric(str_replace('{countryCode}', $countryCode, METRIC_MESSAGES_COUNTRY_CODE), 1);
|
||||
}
|
||||
|
||||
$queueForUsage
|
||||
->setProject($project)
|
||||
->addMetric(METRIC_MESSAGES, 1)
|
||||
->trigger();
|
||||
} catch (\Exception $error) {
|
||||
throw new Exception('Error sending message: ' . $error->getMessage(), 500);
|
||||
}
|
||||
$countryCode = $adapter->getCountryCode($message['to']);
|
||||
if (!empty($countryCode)) {
|
||||
$queueForUsage
|
||||
->addMetric(str_replace('{countryCode}', $countryCode, METRIC_MESSAGES_COUNTRY_CODE), 1);
|
||||
}
|
||||
$queueForUsage
|
||||
->addMetric(METRIC_MESSAGES, 1)
|
||||
->setProject($project)
|
||||
->trigger();
|
||||
} catch (\Throwable $e) {
|
||||
throw new \Exception('Failed sending to targets with error: ' . $e->getMessage());
|
||||
} catch (\Throwable $th) {
|
||||
throw new \Exception('Failed sending to targets with error: ' . $th->getMessage());
|
||||
}
|
||||
};
|
||||
}, $batches));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function getSmsAdapter(Document $provider): ?SMSAdapter
|
||||
{
|
||||
$credentials = $provider->getAttribute('credentials');
|
||||
|
|
|
|||
Loading…
Reference in a new issue