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

Prepare to get conversation number on write

This commit is contained in:
Loic Blot
2018-05-17 09:31:55 +02:00
parent 7bd0ea3af3
commit e63237283f
2 changed files with 20 additions and 3 deletions
+9 -2
View File
@@ -177,15 +177,22 @@
<type>text</type>
<notnull>true</notnull>
<length>64</length>
<primary>true</primary>
</field>
<field>
<name>sms_address</name>
<name>user_id</name>
<type>text</type>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>phone_number</name>
<type>text</type>
<notnull>true</notnull>
<length>512</length>
</field>
<index>
<name>smsdata_conversations_id_address</name>
<name>smsdata_conversations_user_id_address</name>
<field>
<name>id</name>
</field>
+11 -1
View File
@@ -308,6 +308,16 @@ class SmsMapper extends Mapper {
return $phoneList;
}
private function getConversationForUserAndPhone($userId, $phoneNumber) {
$qb->select('id')
->from('ocsms_conversations')
->where($qb->expr()->andX(
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId)),
$qb->expr()->in('phone_number', $qb->createNamedParameter($phoneNumber))
);
$result = $qb->execute();
}
public function writeToDB ($userId, $smsList, $purgeAllSmsBeforeInsert = false) {
$this->db->beginTransaction();
$qb = $this->db->getQueryBuilder();
@@ -348,7 +358,7 @@ class SmsMapper extends Mapper {
(int) $sms["type"]
));
$this->getConversationForUserAndPhone($userId, $sms["address"]);
}
$this->db->commit();