[PATCH] priority with sqlbox
Giulio Giovannini <[email protected]> Wed, 27 Apr 2016 15:03:43 +0200
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <CAPe=cWZNBC7nFBUf-ppLg6n9Rud8smJM2a6zKvLREWUFRQbSwg@mail.gmail.com> |
Hi all, I needed to be able to pass the 'priority' parameter to the bearerbox using the sqlbox so I developed the patch in the attachement. It has been working in production for a while now. My setup is very easy: sqlbox is attached to bearerbox and is used to inject SMS into bearerbox with simple inserts in sqlbox MySQL send_sms table. I haven't got a smsbox attached to the sqlbox so I don't know if there might be issues with that. The patch only works for MySQL. Best regards, Giulio Giovannini -- Mobyt S.p.A. Via Aldighieri, 10 - 44121 Ferrara - Italy ------------------------------------------ Phone : +39 0532 207296 - Fax : +39 0532 242952 E-mail: [email protected] - Web: http://www.mobyt.it Mobyt ® - messaging services
sqlbox_priority.patch
(application/octet-stream, 5.9 KB)
Index: gw/sqlbox_mysql.c
===================================================================
--- gw/sqlbox_mysql.c (revision 56)
+++ gw/sqlbox_mysql.c (working copy)
@@ -146,6 +146,7 @@
msg->sms.charset = octstr_null_create(row[23]);
msg->sms.binfo = octstr_null_create(row[25]);
msg->sms.meta_data = octstr_null_create(row[26]);
+ msg->sms.priority = atol_null(row[27]);
if (row[24] == NULL) {
msg->sms.boxc_id= octstr_duplicate(sqlbox_id);
}
@@ -211,6 +212,7 @@
msg->sms.charset = octstr_null_create(row[23]);
msg->sms.binfo = octstr_null_create(row[25]);
msg->sms.meta_data = octstr_null_create(row[26]);
+ msg->sms.priority = atol_null(row[27]);
if (row[24] == NULL) {
msg->sms.boxc_id= octstr_duplicate(sqlbox_id);
}
@@ -263,7 +265,7 @@
st_num(msg->sms.mclass), st_num(msg->sms.mwi), st_num(msg->sms.coding), st_num(msg->sms.compress),
st_num(msg->sms.validity), st_num(msg->sms.deferred), st_num(msg->sms.dlr_mask), st_str(msg->sms.dlr_url),
st_num(msg->sms.pid), st_num(msg->sms.alt_dcs), st_num(msg->sms.rpi), st_str(msg->sms.charset),
- st_str(msg->sms.boxc_id), st_str(msg->sms.binfo), st_str(msg->sms.meta_data), st_str(msg->sms.foreign_id));
+ st_str(msg->sms.boxc_id), st_str(msg->sms.binfo), st_str(msg->sms.meta_data), st_num(msg->sms.priority), st_str(msg->sms.foreign_id));
sql_update(sql);
while (stuffcount > 0) {
octstr_destroy(stuffer[--stuffcount]);
@@ -287,7 +289,7 @@
/* convert into urlencoded tekst first */
octstr_url_encode(msg->sms.msgdata);
octstr_url_encode(msg->sms.udhdata);
- octstr_format_append(values, "%S (NULL, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S)",
+ octstr_format_append(values, "%S (NULL, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S)",
sep, st_str(momt), st_str(msg->sms.sender),
st_str(msg->sms.receiver), st_str(msg->sms.udhdata), st_str(msg->sms.msgdata), st_num(msg->sms.time),
st_str(msg->sms.smsc_id), st_str(msg->sms.service), st_str(msg->sms.account), st_num(msg->sms.sms_type),
@@ -294,7 +296,7 @@
st_num(msg->sms.mclass), st_num(msg->sms.mwi), st_num(msg->sms.coding), st_num(msg->sms.compress),
st_num(msg->sms.validity), st_num(msg->sms.deferred), st_num(msg->sms.dlr_mask), st_str(msg->sms.dlr_url),
st_num(msg->sms.pid), st_num(msg->sms.alt_dcs), st_num(msg->sms.rpi), st_str(msg->sms.charset),
- st_str(msg->sms.boxc_id), st_str(msg->sms.binfo), st_str(msg->sms.meta_data), st_str(msg->sms.foreign_id));
+ st_str(msg->sms.boxc_id), st_str(msg->sms.binfo), st_str(msg->sms.meta_data), st_num(msg->sms.priority), st_str(msg->sms.foreign_id));
}
octstr_format_append(ids, "%S %S", sep, msg->sms.foreign_id);
msg_destroy(msg);
Index: gw/sqlbox_mysql.h
===================================================================
--- gw/sqlbox_mysql.h (revision 56)
+++ gw/sqlbox_mysql.h (working copy)
@@ -13,7 +13,7 @@
dlr_mask BIGINT(20) NULL, dlr_url VARCHAR(255) NULL, pid BIGINT(20) NULL, \
alt_dcs BIGINT(20) NULL, rpi BIGINT(20) NULL, charset VARCHAR(255) NULL, \
boxc_id VARCHAR(255) NULL, binfo VARCHAR(255) NULL, meta_data TEXT, \
-foreign_id VARCHAR(255) NULL)"
+priority BIGINT(20) NULL, foreign_id VARCHAR(255) NULL)"
#define SQLBOX_MYSQL_CREATE_INSERT_TABLE "CREATE TABLE IF NOT EXISTS %S ( \
sql_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, \
@@ -26,29 +26,29 @@
dlr_mask BIGINT(20) NULL, dlr_url VARCHAR(255) NULL, pid BIGINT(20) NULL, \
alt_dcs BIGINT(20) NULL, rpi BIGINT(20) NULL, charset VARCHAR(255) NULL, \
boxc_id VARCHAR(255) NULL, binfo VARCHAR(255) NULL, meta_data TEXT, \
-foreign_id VARCHAR(255) NULL)"
+priority BIGINT(20) NULL, foreign_id VARCHAR(255) NULL)"
#define SQLBOX_MYSQL_SELECT_QUERY "SELECT sql_id, momt, sender, receiver, udhdata, \
msgdata, time, smsc_id, service, account, id, sms_type, mclass, mwi, coding, \
compress, validity, deferred, dlr_mask, dlr_url, pid, alt_dcs, rpi, \
-charset, boxc_id, binfo, meta_data FROM %S LIMIT 0,1"
+charset, boxc_id, binfo, meta_data, priority FROM %S LIMIT 0,1"
#define SQLBOX_MYSQL_SELECT_LIST_QUERY "SELECT sql_id, momt, sender, receiver, udhdata, \
msgdata, time, smsc_id, service, account, id, sms_type, mclass, mwi, coding, \
compress, validity, deferred, dlr_mask, dlr_url, pid, alt_dcs, rpi, \
-charset, boxc_id, binfo, meta_data FROM %S LIMIT 0,%ld"
+charset, boxc_id, binfo, meta_data, priority FROM %S LIMIT 0,%ld"
#define SQLBOX_MYSQL_INSERT_QUERY "INSERT INTO %S ( sql_id, momt, sender, \
receiver, udhdata, msgdata, time, smsc_id, service, account, sms_type, \
mclass, mwi, coding, compress, validity, deferred, dlr_mask, dlr_url, \
-pid, alt_dcs, rpi, charset, boxc_id, binfo, meta_data, foreign_id ) VALUES ( \
+pid, alt_dcs, rpi, charset, boxc_id, binfo, meta_data, priority, foreign_id ) VALUES ( \
NULL, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S, \
-%S, %S, %S, %S, %S, %S, %S, %S, %S, %S)"
+%S, %S, %S, %S, %S, %S, %S, %S, %S, %S, %S)"
#define SQLBOX_MYSQL_INSERT_LIST_QUERY "INSERT INTO %S ( sql_id, momt, sender, \
receiver, udhdata, msgdata, time, smsc_id, service, account, sms_type, \
mclass, mwi, coding, compress, validity, deferred, dlr_mask, dlr_url, \
-pid, alt_dcs, rpi, charset, boxc_id, binfo, meta_data, foreign_id ) VALUES %S"
+pid, alt_dcs, rpi, charset, boxc_id, binfo, meta_data, priority, foreign_id ) VALUES %S"
#define SQLBOX_MYSQL_DELETE_QUERY "DELETE FROM %S WHERE sql_id = %S"
#define SQLBOX_MYSQL_DELETE_LIST_QUERY "DELETE FROM %S WHERE sql_id in (%S)"