unxsSMS
New unxsVZ sub project for providing SMS gateway preprocessor for message digests and other limits.
Major Requirements
Must be able to limit number of SMS messages sent during arbitrary time interval configurable per phone number.
Must be able to create and send a digest SMS for given phone number based queued SMS messages.
Intial "How it will work"
We need a table of phone numbers with settings and counters. The settings are uTimeInterval, uDailyMax, cPrimaryGatewayURL, cSecondaryGatewayURL. The counters are uTimeIntervalCount and uDailyCount.
We need a a table for incoming queued messages (digests can be created here.) Initial message (uTimeIntervalCount==0) can be sent immediately (but we uTimeIntervalCount++), if another message comes in during uTimeInterval and uTimeIntervalCount>0 then a digest is created and the digest is not sent until uTimeInterval returns to zero again. Once an SMS is sent it is removed from the queue. This queue is by definition limited to one entry per phone number. If the message can't be sent immediately it is placed in an outgoing queue, therefore...
We need a queue for outgoing messages for when the SMS gateway fails. This can be limited to one per phone number as a different type of SMS gateway failure digest. This queue would not use a time interval for digests since it's contents depends on an external SMS gateway provider. But by definition is limited one entry per phone number.
Definitions
Digest: Summary SMS message related to more than one SMS. Can be something as simple as replacing first to arrive SMS message of a group of SMS messages sent to same phone number with a prefix line D(N): then the original message (maybe truncated to fit into SMS limit); where N is number of messages received and folded into the single digest SMS. If SMS gateway fails the short prefix could be F(N).
Time interval: A window of seconds where we count incoming messages (it also is a minimum delay interval for digest messages.) No SMS message digests are sent until this interval is over. This sets a maximum number of messages per hour that can be sent to a given phone number to 3600/uTimeInterval. E.g. if uTimeInterval=300 then a maximum of 12 messages per hour will be forwarded to SMS gateway. In other words no matter how many messages are received only one will be sent every 5 minutes.
Daily maximum: Maximum number of messages sent per day. E.g. if uDailyMax=20 then all messages including digests after 20 during last day will not be sent to SMS gateway.
Time interval count: Number of incoming messages queued per phone number during time interval window seconds.
