1
0
mirror of https://github.com/nextcloud/ocsms.git synced 2026-08-11 16:32:55 +00:00

Really fix the thing into conversations

This commit is contained in:
Loic Blot
2014-10-22 16:02:13 +00:00
parent 74511c4c60
commit 20db5d6a7f
3 changed files with 34 additions and 16 deletions
+16
View File
@@ -111,6 +111,22 @@ class SmsMapper extends Mapper {
}
}
public function getLastMessageTimestampForAllPhonesNumbers ($userId) {
$query = \OCP\DB::prepare('SELECT sms_address,MAX(sms_date) as mx FROM ' .
'*PREFIX*ocsms_smsdatas WHERE user_id = ? AND sms_mailbox IN (?,?) ' .
'GROUP BY sms_address');
$result = $query->execute(array($userId, 0, 1));
$phoneList = array();
while ($row = $result->fetchRow()) {
$phoneNumber = preg_replace("#[ ]#", "/", $row["sms_address"]);
if (!in_array($phoneNumber, $phoneList)) {
$phoneList[$phoneNumber] = $row["mx"];
}
}
return $phoneList;
}
public function writeToDB ($userId, $smsList, $purgeAllSmsBeforeInsert = false) {
\OCP\DB::beginTransaction();