From 0132ca90dbc18953253f77c3cebfe61e4c1e14cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot=20=28=40U-Exp=29?= Date: Fri, 12 Sep 2014 19:42:54 +0200 Subject: [PATCH] Change protocol. We receive a mailbox ID, drafts are contained into this mailbox ID. --- appinfo/database.xml | 10 ++++++++-- appinfo/info.xml | 2 +- controller/smscontroller.php | 13 +++++++------ db/smsmapper.php | 7 +++---- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/appinfo/database.xml b/appinfo/database.xml index f9fd04a..fc9cdd7 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -63,8 +63,14 @@ sms_flags text true - 000 - 3 + 00 + 2 + + + sms_mailbox + integer + true + 1 diff --git a/appinfo/info.xml b/appinfo/info.xml index c4b6424..0016559 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,6 +5,6 @@ Owncloud SMS app AGPL Loic Blot - 0.1.4 + 0.1.5 7 diff --git a/controller/smscontroller.php b/controller/smscontroller.php index c76e02a..54a2cf3 100644 --- a/controller/smscontroller.php +++ b/controller/smscontroller.php @@ -60,20 +60,23 @@ class SmsController extends Controller { foreach ($smsDatas as &$sms) { if (!array_key_exists("_id", $sms) || !array_key_exists("read", $sms) || !array_key_exists("date", $sms) || !array_key_exists("seen", $sms) || + !array_key_exists("mbox", $sms) || !array_key_exists("body", $sms) || !array_key_exists("address", $sms)) { $this->errorMsg = "Error: bad SMS entry"; return false; } - if (!array_key_exists("draft", $sms)) { - $sms["draft"] = "true"; - } - if (!is_numeric($sms["_id"])) { $this->errorMsg = sprintf("Error: Invalid SMS ID '%s'", $sms["_id"]); return false; } + if (!is_numeric($sms["mbox"]) && $sms["mbox"] != 0 && $sms["mbox"] != 1 && + $sms["mbox"] != 2) { + $this->errorMsg = sprintf("Error: Invalid Mailbox ID '%s'", $sms["mbox"]); + return false; + } + if ($sms["read"] !== "true" && $sms["read"] !== "false") { $this->errorMsg = sprintf("Error: Invalid SMS Read state '%s'", $sms["read"]); return false; @@ -98,6 +101,4 @@ class SmsController extends Controller { } return true; } - - } diff --git a/db/smsmapper.php b/db/smsmapper.php index 118dfea..6760406 100644 --- a/db/smsmapper.php +++ b/db/smsmapper.php @@ -23,15 +23,14 @@ class SmsMapper extends Mapper { // @TODO public function saveAll($userId, $smsList) { foreach ($smsList as $sms) { - $smsFlags = sprintf("%s%s%s", + $smsFlags = sprintf("%s%s", $sms["read"] === "true" ? "1" : "0", - $sms["seen"] === "true" ? "1" : "0", - $sms["draft"] === "true" ? "1" : "0" + $sms["seen"] === "true" ? "1" : "0" ); $query = \OC_DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' . '(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' . - 'sms_address, sms_msg) VALUES ' . + 'sms_address, sms_msg, sms_mailbox) VALUES ' . '(?,?,?,?,?,?,?,?)'); $result = $query->execute(array( $userId, "NOW()", "NOW()", $smsFlags,