Update received to use phone_id instead of destination

This commit is contained in:
osaajani 2020-03-31 01:53:07 +02:00
parent 78abbef26e
commit 2ae2baa6c4
7 changed files with 61 additions and 52 deletions

View file

@ -33,23 +33,23 @@ namespace controllers\internals;
* Create a received.
*
* @param $id_user : Id of user to create received for
* @param int $id_phone : Id of the number the message was send with
* @param $at : Reception date
* @param $text : Text of the message
* @param string $origin : Number of the sender
* @param string $destination : Number of the receiver
* @param string $status : Status of the received message
* @param bool $command : Is the sms a command
*
* @return bool : false on error, new received id else
*/
public function create(int $id_user, $at, string $text, string $origin, string $destination, string $status = 'unread', bool $command = false): bool
public function create(int $id_user, int $id_phone, $at, string $text, string $origin, string $status = 'unread', bool $command = false): bool
{
$received = [
'id_user' => $id_user,
'id_phone' => $id_phone,
'at' => $at,
'text' => $text,
'origin' => $origin,
'destination' => $destination,
'status' => $status,
'command' => $command,
];
@ -57,34 +57,6 @@ namespace controllers\internals;
return (bool) $this->get_model()->insert($received);
}
/**
* Update a received for a user.
*
* @param int $id_user : user id
* @param int $id_received : received id
* @param $at : Reception date
* @param $text : Text of the message
* @param string $origin : Number of the sender
* @param string $destination : Number of the receiver
* @param string $status : Status of the received message
* @param bool $command : Is the sms a command
*
* @return bool : false on error, true on success
*/
public function update_for_user(int $id_user, int $id_received, $at, string $text, string $origin, string $destination, string $status = 'unread', bool $command = false): bool
{
$received = [
'at' => $at,
'text' => $text,
'origin' => $origin,
'destination' => $destination,
'status' => $status,
'command' => $command,
];
return (bool) $this->get_model()->update_for_user($id_user, $id_received, $received);
}
/**
* Update a received message for a user to mark the message as read.
*
@ -218,7 +190,7 @@ namespace controllers\internals;
}
/**
* Find destination of last received message for an origin and user.
* Find last received message for an origin and user.
*
* @param int $id_user : User id
* @param string $origin : Origin number