1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-10 17:36:21 +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
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
2 changed files with 20 additions and 3 deletions

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>

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();