playSMS Forum

Duplicate '_tblSMSInbox' entries

I want to create a shared routed inbox based on the receiving number, was able to make it work by setting up the sender_id in the ‘route incoming SMS’ section.

My current problem is that when the settings of sender_id in the ‘route incoming SMS’ section is copied to another user, the entries in ‘_tblSMSInbox’ table is multiplied exponentially based on the number of users.

Example, I have two users with the same settings and the entries in ‘_tblSMSInbox’ are 4. Tried using three users and the entries are 9. Basically looping and making a copy for each user, looping based on the number of users.

Would like to know if there’s a workaround for this and make it just 1. Was fiddling with \core\recvsms\fn.php but haven’t worked it out yet.

‘_tblRecvSMS’ is okay and the copy is single.

what do you mean by “copied” ?
what entries that are doubled in tblSMSInbox ? SMS on inbox ?

anton

Hello anton,

Copied means I used the same sender_id on different users.

The effect of this is that the entries on the ‘_tblSMSInbox’ are duplicated based on the number of users with the same sender_id. See below:

Do you edit some codes ? I tested just now and I can only route to 1 of 2 users with the same sender ID, to the first user.

anton

Log when there’s two users with same sender_id

192.168.0.196 192.168.0.98 2020-12-17 23:09:47 PID5fdc55bb43136 - L2 openvox__callback # pushed phonenumber:+639xxxxxxxx0 port:38 portname:OpenVoxPort message:Two users sms_datetime:2020/12/18 15:09:44 key:515020237057724 id:smslog_id 
192.168.0.196 192.168.0.98 2020-12-17 23:09:47 PID5fdc55bb43136 - L2 openvox__callback # incoming smsc: from:+639xxxxxxxx0 port:38 m:[Two users] smsc:[]
192.168.0.196 192.168.0.98 2020-12-17 23:09:47 PID5fdc55bb43136 - L3 recvsms # isrecvsmsd:1 dt:2020-12-17 23:09:47 sender:+639xxxxxxxx0 m:Two users receiver:38 smsc:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 recvsmsd # id:6572 dt:2020-12-17 23:09:47 sender:+639xxxxxxxx0 m:Two users receiver:38 smsc:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 recvsms_process # dt:2020-12-17 23:09:47 sender:+639xxxxxxxx0 m:Two users receiver:38 smsc:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 recvsms_process # unhandled datetime:2020-12-17 23:09:47 sender:+639xxxxxxxx0 receiver:38 message:Two users
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-17 23:09:47 s:+639xxxxxxxx0 r:38 m:[Two users]
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user01 reference_id:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10056 sender:+639xxxxxxxx0 receiver:38 target:user01
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-17 23:09:47 s:+639xxxxxxxx0 r:38 m:[Two users]
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user02 reference_id:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10057 sender:+639xxxxxxxx0 receiver:38 target:user02
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-17 23:09:47 s:+639xxxxxxxx0 r:38 m:[Two users]
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user01 reference_id:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10058 sender:+639xxxxxxxx0 receiver:38 target:user01
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-17 23:09:47 s:+639xxxxxxxx0 r:38 m:[Two users]
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user02 reference_id:
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10059 sender:+639xxxxxxxx0 receiver:38 target:user02
- - 2020-12-18 15:09:48 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02

Log when there’s three users with same sender_id

192.168.0.196 192.168.0.98 2020-12-17 23:12:07 PID5fdc564745825 - L2 openvox__callback # pushed phonenumber:+639xxxxxxxx0 port:38 portname:OpenVoxPort message:Three users sms_datetime:2020/12/18 15:12:04 key:515020237057724 id:smslog_id 
192.168.0.196 192.168.0.98 2020-12-17 23:12:07 PID5fdc564745825 - L2 openvox__callback # incoming smsc: from:+639xxxxxxxx0 port:38 m:[Three users] smsc:[]
192.168.0.196 192.168.0.98 2020-12-17 23:12:07 PID5fdc564745825 - L3 recvsms # isrecvsmsd:1 dt:2020-12-17 23:12:07 sender:+639xxxxxxxx0 m:Three users receiver:38 smsc:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 recvsmsd # id:6573 dt:2020-12-17 23:12:07 sender:+639xxxxxxxx0 m:Three users receiver:38 smsc:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 recvsms_process # dt:2020-12-17 23:12:07 sender:+639xxxxxxxx0 m:Three users receiver:38 smsc:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 recvsms_process # unhandled datetime:2020-12-17 23:12:07 sender:+639xxxxxxxx0 receiver:38 message:Three users
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user01 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10060 sender:+639xxxxxxxx0 receiver:38 target:user01
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user02 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10061 sender:+639xxxxxxxx0 receiver:38 target:user02
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user03 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user03 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10062 sender:+639xxxxxxxx0 receiver:38 target:user03
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user03
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user01 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10063 sender:+639xxxxxxxx0 receiver:38 target:user01
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user02 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10064 sender:+639xxxxxxxx0 receiver:38 target:user02
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user03 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user03 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10065 sender:+639xxxxxxxx0 receiver:38 target:user03
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user03
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user01 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10066 sender:+639xxxxxxxx0 receiver:38 target:user01
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user02 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10067 sender:+639xxxxxxxx0 receiver:38 target:user02
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user03 dt:2020-12-17 23:12:07 s:+639xxxxxxxx0 r:38 m:[Three users]
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:+639xxxxxxxx0 receiver:38 target:user03 reference_id:
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10068 sender:+639xxxxxxxx0 receiver:38 target:user03
- - 2020-12-18 15:12:08 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user03

Inbox of two users

The only code I edited was to enable the GSM port setting up in the Openvox plugin.

- plugin/gateway/openvox/fn.php
- plugin/gateway/openvox/config.php

I can add the same sender_id to multiple user in the Manage sender ID section, see below:

for now I just want to point the routing of incoming SMS with matched sender ID is here:

Im testing with simulate incoming sms, seems like different results if using real gateway

anton

Thanks for this, will try to study that part. Might be the source of loop.

Here’s the log using simulate incoming SMS:

192.168.0.92 192.168.0.98 2020-12-18 00:02:03 PID5fdc61fb91ad5 - L3 auth_validate_login # login attempt u:admin uid:1 p:be2dcb69fb0ff2aad903a16057541cdc ip:192.168.0.92
192.168.0.92 192.168.0.98 2020-12-18 00:02:03 PID5fdc61fb91ad5 - L2 auth_validate_login # valid login u:admin uid:1 ip:192.168.0.92
192.168.0.92 192.168.0.98 2020-12-18 00:02:03 PID5fdc61fb91ad5 - L2 login # u:admin uid:1 status:2 sid:98sppiheh65p1ailgoeift125m ip:192.168.0.92
192.168.0.92 192.168.0.98 2020-12-18 00:25:49 PID5fdc678d9e0ca admin L3 recvsms # isrecvsmsd:1 dt:2020-12-18 00:25:31 sender:629876543210 m:Test using Simulate incoming SMS  receiver:38 smsc:dev
192.168.0.92 192.168.0.98 2020-12-18 00:25:49 PID5fdc678d9e0ca admin L3 dev__incoming # Array (     [0] => Sender ID: 629876543210     [1] => Receiver number: 38     [2] => Sent: 2020-12-18 00:25:31     [3] => Message: Test using Simulate incoming SMS  ) 
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 recvsmsd # id:6583 dt:2020-12-18 00:25:31 sender:629876543210 m:Test using Simulate incoming SMS  receiver:38 smsc:dev
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 recvsms_process # dt:2020-12-18 00:25:31 sender:629876543210 m:Test using Simulate incoming SMS  receiver:38 smsc:dev
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 recvsms_process # unhandled datetime:2020-12-18 00:25:31 sender:629876543210 receiver:38 message:Test using Simulate incoming SMS 
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10115 sender:629876543210 receiver:38 target:user
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user01 reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10116 sender:629876543210 receiver:38 target:user01
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user02 reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10117 sender:629876543210 receiver:38 target:user02
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10118 sender:629876543210 receiver:38 target:user
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user01 reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10119 sender:629876543210 receiver:38 target:user01
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user02 reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10120 sender:629876543210 receiver:38 target:user02
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10121 sender:629876543210 receiver:38 target:user
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user01 dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user01 reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10122 sender:629876543210 receiver:38 target:user01
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user01
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender start u:user02 dt:2020-12-18 00:25:31 s:629876543210 r:38 m:[Test using Simulate incoming SMS ]
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saving sender:629876543210 receiver:38 target:user02 reference_id:
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L2 recvsms_inbox_add # saved id:10123 sender:629876543210 receiver:38 target:user02
- - 2020-12-18 16:25:50 PID5fc9ec37bfa28 - L3 incoming__recvsms_intercept_after # sandbox match sender end u:user02

Here’s the database entries, still duplicate.

hmm ok.

so, incoming SMS from gateway/sms will run recvsms() and will write to tblRecvSMS. In this part its important that the entry is only 1 for 1 incoming SMS.

and then, playSMS daemon will run recvsmsd() and it reads tblRecvSMS, when found new incoming SMS it will run recvsms_process()

recvsms_process() runs recvsms_intercept_after()

recvsms_intercept_after() will run incoming_hook_recvsms_intercept_after()

parts of incoming_hook_recvsms_intercept_after() gather users with the same sender ID and then run recvsms_inbox_add(), this is where incoming SMS actually written to tblSMSInbox

fyi, any recvsms_*() is in core/recvsms/fn.php and incoming_*() in feature/incoming/fn.php

anton