Skip to content

Commit e632372

Browse files
committed
Prepare to get conversation number on write
1 parent 7bd0ea3 commit e632372

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

appinfo/database.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,22 @@
177177
<type>text</type>
178178
<notnull>true</notnull>
179179
<length>64</length>
180+
<primary>true</primary>
180181
</field>
181182
<field>
182-
<name>sms_address</name>
183+
<name>user_id</name>
184+
<type>text</type>
185+
<notnull>true</notnull>
186+
<length>64</length>
187+
</field>
188+
<field>
189+
<name>phone_number</name>
183190
<type>text</type>
184191
<notnull>true</notnull>
185192
<length>512</length>
186193
</field>
187194
<index>
188-
<name>smsdata_conversations_id_address</name>
195+
<name>smsdata_conversations_user_id_address</name>
189196
<field>
190197
<name>id</name>
191198
</field>

db/smsmapper.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ public function getNewMessagesCountForAllPhonesNumbers($userId, $lastDate) {
308308
return $phoneList;
309309
}
310310

311+
private function getConversationForUserAndPhone($userId, $phoneNumber) {
312+
$qb->select('id')
313+
->from('ocsms_conversations')
314+
->where($qb->expr()->andX(
315+
$qb->expr()->eq('user_id', $qb->createNamedParameter($userId)),
316+
$qb->expr()->in('phone_number', $qb->createNamedParameter($phoneNumber))
317+
);
318+
$result = $qb->execute();
319+
}
320+
311321
public function writeToDB ($userId, $smsList, $purgeAllSmsBeforeInsert = false) {
312322
$this->db->beginTransaction();
313323
$qb = $this->db->getQueryBuilder();
@@ -348,7 +358,7 @@ public function writeToDB ($userId, $smsList, $purgeAllSmsBeforeInsert = false)
348358
(int) $sms["type"]
349359
));
350360

351-
361+
$this->getConversationForUserAndPhone($userId, $sms["address"]);
352362
}
353363

354364
$this->db->commit();

0 commit comments

Comments
 (0)