flexisip-account-manager/flexiapi/app/Rules/AudioMime.php
Timothée Jaussoin eeeb6baf74 Fix FLEXIAPI-366 Send the voicemails by email
Add a Voicemail UI to listen and delete voicemails in the Admin Account view
2025-12-11 17:20:56 +01:00

38 lines
844 B
PHP

<?php
namespace App\Rules;
use App\AccountFile;
use Illuminate\Contracts\Validation\Rule;
class AudioMime implements Rule
{
public function __construct(private AccountFile $accountFile)
{
}
public function passes($attribute, $file): bool
{
$mimeType = null;
switch ($file->getMimeType()) {
case 'audio/opus':
$mimeType = 'audio/opus';
break;
case 'audio/vnd.wave':
case 'audio/wav':
case 'audio/wave':
case 'audio/x-wav':
case 'audio/x-pn-wav':
$mimeType = 'audio/wav';
break;
}
return $this->accountFile->content_type == $mimeType;
}
public function message()
{
return __('The file should have the declared mime-type');
}
}