mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-31 02:17:38 +00:00 
			
		
		
		
	Change protocol. We receive a mailbox ID, drafts are contained into this mailbox ID.
This commit is contained in:
		
							parent
							
								
									5cef955d23
								
							
						
					
					
						commit
						0132ca90db
					
				| @ -63,8 +63,14 @@ | ||||
| 				<name>sms_flags</name> | ||||
| 				<type>text</type> | ||||
| 				<notnull>true</notnull> | ||||
| 				<default>000</default> | ||||
| 				<length>3</length> | ||||
| 				<default>00</default> | ||||
| 				<length>2</length> | ||||
| 			</field> | ||||
| 			<field> | ||||
| 				<name>sms_mailbox</name> | ||||
| 				<type>integer</type> | ||||
| 				<notnull>true</notnull> | ||||
| 				<length>1</length> | ||||
| 			</field> | ||||
| 		</declaration> | ||||
| 	</table> | ||||
|  | ||||
| @ -5,6 +5,6 @@ | ||||
|     <description>Owncloud SMS app</description> | ||||
|     <licence>AGPL</licence> | ||||
|     <author>Loic Blot</author> | ||||
|     <version>0.1.4</version> | ||||
|     <version>0.1.5</version> | ||||
|     <requiremin>7</requiremin> | ||||
| </info> | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user