mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +00:00
Bugfix: check the read date per phone number if there are messages to check for this date
This commit is contained in:
parent
debf173673
commit
631640c5bb
@ -232,9 +232,11 @@ class SmsMapper extends Mapper {
|
||||
while ($row = $result->fetchRow()) {
|
||||
$phoneNumber = preg_replace("#[ ]#", "/", $row["sms_address"]);
|
||||
if (!in_array($phoneNumber, $phoneList)) {
|
||||
if ($this->getLastReadDateForPhoneNumber($userId, $phoneNumber) < $lastDate) {
|
||||
$phoneList[$phoneNumber] = $row["ct"];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $phoneList;
|
||||
}
|
||||
|
||||
@ -248,6 +250,22 @@ class SmsMapper extends Mapper {
|
||||
if ($row = $result->fetchRow()) {
|
||||
return $row["mx"];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getLastReadDateForPhoneNumber ($userId, $phoneNumber) {
|
||||
$sql = 'SELECT MAX(datavalue) as mx FROM ' .
|
||||
'*PREFIX*ocsms_user_datas WHERE user_id = ? AND datakey = ?';
|
||||
|
||||
$query = \OCP\DB::prepare($sql);
|
||||
$result = $query->execute(array($userId, 'lastReadDate-' . $phoneNumber));
|
||||
|
||||
if ($row = $result->fetchRow()) {
|
||||
return $row["mx"];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function setLastReadDate ($userId, $phoneNumber, $lastDate) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user