mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Update adapter to not use phone number anymore
This commit is contained in:
parent
d5be760843
commit
78abbef26e
5 changed files with 15 additions and 26 deletions
|
@ -23,10 +23,9 @@ namespace adapters;
|
||||||
/**
|
/**
|
||||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||||
*
|
*
|
||||||
* @param string $number : Phone number the adapter is used for
|
|
||||||
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
||||||
*/
|
*/
|
||||||
public function __construct(string $number, string $datas);
|
public function __construct(string $datas);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classname of the adapter.
|
* Classname of the adapter.
|
||||||
|
|
|
@ -33,12 +33,10 @@ namespace adapters;
|
||||||
/**
|
/**
|
||||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||||
*
|
*
|
||||||
* @param string $number : Phone number the adapter is used for
|
|
||||||
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
||||||
*/
|
*/
|
||||||
public function __construct(string $number, string $datas)
|
public function __construct(string $number, string $datas)
|
||||||
{
|
{
|
||||||
$this->number = $number;
|
|
||||||
$this->datas = json_decode($datas, true);
|
$this->datas = json_decode($datas, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +176,7 @@ namespace adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called to read SMSs of the number.
|
* Method called to read SMSs of the phone
|
||||||
*
|
*
|
||||||
* @return array : Array of the sms reads
|
* @return array : Array of the sms reads
|
||||||
*/
|
*/
|
||||||
|
@ -213,7 +211,6 @@ namespace adapters;
|
||||||
'at' => $decode['at'],
|
'at' => $decode['at'],
|
||||||
'text' => $decode['text'],
|
'text' => $decode['text'],
|
||||||
'origin' => $decode['number'],
|
'origin' => $decode['number'],
|
||||||
'destination' => $this->number,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,6 @@ namespace adapters;
|
||||||
*/
|
*/
|
||||||
class OvhSmsAdapter implements AdapterInterface
|
class OvhSmsAdapter implements AdapterInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Phone number using the adapter.
|
|
||||||
*/
|
|
||||||
private $number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
|
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
|
||||||
*/
|
*/
|
||||||
|
@ -48,10 +43,8 @@ namespace adapters;
|
||||||
* @param string $number : Phone number the adapter is used for
|
* @param string $number : Phone number the adapter is used for
|
||||||
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
||||||
*/
|
*/
|
||||||
public function __construct(string $number, string $datas)
|
public function __construct(string $datas)
|
||||||
{
|
{
|
||||||
$this->number = $number;
|
|
||||||
$this->formatted_number = str_replace('+', '00', $number);
|
|
||||||
$this->datas = json_decode($datas, true);
|
$this->datas = json_decode($datas, true);
|
||||||
|
|
||||||
$this->api = new Api(
|
$this->api = new Api(
|
||||||
|
@ -60,6 +53,9 @@ namespace adapters;
|
||||||
'ovh-eu',
|
'ovh-eu',
|
||||||
$this->datas['consumer_key']
|
$this->datas['consumer_key']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->number = $this->datas['number'];
|
||||||
|
$this->formatted_number = str_replace('+', '00', $this->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,6 +106,12 @@ namespace adapters;
|
||||||
'description' => 'Service Name de votre service SMS chez OVH. Il s\'agit du nom associé à votre service SMS dans la console OVH, probablement quelque chose comme "sms-xxxxx-1" ou "xxxx" est votre identifiant client OVH.',
|
'description' => 'Service Name de votre service SMS chez OVH. Il s\'agit du nom associé à votre service SMS dans la console OVH, probablement quelque chose comme "sms-xxxxx-1" ou "xxxx" est votre identifiant client OVH.',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'name' => 'number',
|
||||||
|
'title' => 'Numéro',
|
||||||
|
'description' => 'Numéro virtuel du téléphone chez OVH.',
|
||||||
|
'required' => true,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'name' => 'app_key',
|
'name' => 'app_key',
|
||||||
'title' => 'Application Key',
|
'title' => 'Application Key',
|
||||||
|
@ -220,7 +222,6 @@ namespace adapters;
|
||||||
'at' => (new \DateTime($sms_details['creationDatetime']))->format('Y-m-d H:i:s'),
|
'at' => (new \DateTime($sms_details['creationDatetime']))->format('Y-m-d H:i:s'),
|
||||||
'text' => $sms_details['message'],
|
'text' => $sms_details['message'],
|
||||||
'origin' => $sms_details['sender'],
|
'origin' => $sms_details['sender'],
|
||||||
'destination' => $this->number,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
|
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
|
||||||
|
|
|
@ -20,11 +20,6 @@ namespace adapters;
|
||||||
*/
|
*/
|
||||||
class TestAdapter implements AdapterInterface
|
class TestAdapter implements AdapterInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Phone number using the adapter.
|
|
||||||
*/
|
|
||||||
private $number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
|
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
|
||||||
*/
|
*/
|
||||||
|
@ -43,12 +38,10 @@ namespace adapters;
|
||||||
/**
|
/**
|
||||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||||
*
|
*
|
||||||
* @param string $number : Phone number the adapter is used for
|
|
||||||
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
|
||||||
*/
|
*/
|
||||||
public function __construct(string $number, string $datas)
|
public function __construct(string $datas)
|
||||||
{
|
{
|
||||||
$this->number = $number;
|
|
||||||
$this->datas = $datas;
|
$this->datas = $datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +160,6 @@ namespace adapters;
|
||||||
/**
|
/**
|
||||||
* Method called on reception of a status update notification for a SMS.
|
* Method called on reception of a status update notification for a SMS.
|
||||||
*
|
*
|
||||||
* @return mixed : False on error, else array ['uid' => uid of the sms, 'status' => New status of the sms ('unknown', 'delivered', 'failed')]
|
|
||||||
*/
|
*/
|
||||||
public static function status_change_callback()
|
public static function status_change_callback()
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ class Phone extends AbstractDaemon
|
||||||
|
|
||||||
//Instanciate adapter
|
//Instanciate adapter
|
||||||
$adapter_class = $this->phone['adapter'];
|
$adapter_class = $this->phone['adapter'];
|
||||||
$this->adapter = new $adapter_class($this->phone['number'], $this->phone['adapter_datas']);
|
$this->adapter = new $adapter_class($this->phone['adapter_datas']);
|
||||||
|
|
||||||
$this->logger->info('Starting Phone daemon with pid ' . getmypid());
|
$this->logger->info('Starting Phone daemon with pid ' . getmypid());
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ class Phone extends AbstractDaemon
|
||||||
|
|
||||||
$this->process_for_transfer($sms, $user_settings);
|
$this->process_for_transfer($sms, $user_settings);
|
||||||
|
|
||||||
$internal_received->create($this->phone['id_user'], $sms['at'], $sms['text'], $sms['origin'], $sms['destination'], 'unread', $is_command);
|
$internal_received->create($this->phone['id_user'], $this->phone['id'], $sms['at'], $sms['text'], $sms['origin'], 'unread', $is_command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue