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:
parent
7bd0ea3af3
commit
e63237283f
@ -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>
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user