Re: [PATCH] SQLBOX Delivery Reports Insert
"Mi Reflejo" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
You can filter out dlr by sms_type with a statement like (..)WHERE
sms_type=3; if you want to keep delivery reports for any reason so i suggest
to ignore "ACK/" messages that bearerbox sends. These kind of msg are
useless.
I'm attaching my suggested patch. (Tested and working)
And of course if the table already exists you must to do: alter table
sent_sms modify momt enum('MO','MT','DLR');
Regards,
Martin
On 5/18/06, Rene Kluwen <[email protected]> wrote:
>
> Maybe we should better introduce another type, besides MT & MO (e.g. DR
> for
> Delivery Report)?
> This way delivery reports can be filtered out with ease by constructing a
> proper SQL statement.
>
> The reasons that I would prefer this way are:
> 1. Backwards compatibility, and
> 2. Some people are counting on delivery reports being inserted. They are
> not
> in all cases completely "unneccesary".
>
> Another idea is to make this behaviour configurable.
>
> Comments?
>
> Rene Kluwen
> Chimit
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]On
> Behalf Of Mi Reflejo
> Sent: zaterdag 13 mei 2006 14:24
> To: [email protected]
> Subject: [PATCH] SQLBOX Delivery Reports Insert
>
>
> *gw/sqlbox.c
> -Removed unnecessary INSERT's into database.
> bearerbox_to_smsbox shouldn't INSERT delivery reports as type "MO".
> condition added to discard delivery reports.
>
>
delivery_logtable_fix.patch
(application/octet-stream, 5.9 KB)
--- sqlbox.c.orig 2006-05-18 21:43:38.000000000 -0600
+++ sqlbox.c 2006-05-18 21:52:14.000000000 -0600
@@ -341,8 +341,11 @@
msg_destroy(msg);
break;
}
- if (msg_type(msg) == sms) {
- gw_sql_save_msg(msg, octstr_imm("MO"));
+ if ((msg_type(msg) == sms) && (strcmp(octstr_get_cstr(msg->sms.msgdata),"ACK/") != 0)) {
+ if (msg->sms.sms_type != report_mo)
+ gw_sql_save_msg(msg, octstr_imm("MO"));
+ else
+ gw_sql_save_msg(msg, octstr_imm("DLR"));
}
send_msg(conn->smsbox_connection, conn, msg);
msg_destroy(msg);
@@ -454,8 +457,11 @@
debug("sqlbox", 0, "bearerbox_to_sql: connection to bearerbox died.");
break;
}
- if (msg_type(msg) == sms) {
- gw_sql_save_msg(msg, octstr_imm("MO"));
+ if ((msg_type(msg) == sms) && (strcmp(octstr_get_cstr(msg->sms.msgdata),"ACK/") != 0)) {
+ if (msg->sms.sms_type != report_mo)
+ gw_sql_save_msg(msg, octstr_imm("MO"));
+ else
+ gw_sql_save_msg(msg, octstr_imm("DLR"));
}
msg_destroy(msg);
}
--- sqlbox_mysql.c.orig 2006-05-18 22:03:20.000000000 -0600
+++ sqlbox_mysql.c 2006-05-18 22:00:52.000000000 -0600
@@ -91,7 +91,7 @@
}
/* create send_sms && sent_sms tables if they do not exist */
- sql = octstr_format("CREATE TABLE IF NOT EXISTS %S (sql_id bigint(20) not null auto_increment primary key, momt enum('MO', 'MT') null, sender varchar(20) null, receiver varchar(20) null, udhdata blob null, msgdata text null, time bigint(20) null, smsc_id varchar(255) null, service varchar(255) null, account varchar(255) null, id bigint(20) null, sms_type bigint(20) null, mclass bigint(20) null, mwi bigint(20) null, coding bigint(20) null, compress bigint(20) null, validity bigint(20) null, deferred bigint(20) null, 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)", sqlbox_logtable);
+ sql = octstr_format("CREATE TABLE IF NOT EXISTS %S (sql_id bigint(20) not null auto_increment primary key, momt enum('MO', 'MT', 'DLR') null, sender varchar(20) null, receiver varchar(20) null, udhdata blob null, msgdata text null, time bigint(20) null, smsc_id varchar(255) null, service varchar(255) null, account varchar(255) null, id bigint(20) null, sms_type bigint(20) null, mclass bigint(20) null, mwi bigint(20) null, coding bigint(20) null, compress bigint(20) null, validity bigint(20) null, deferred bigint(20) null, 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)", sqlbox_logtable);
sql_update(sql);
octstr_destroy(sql);
sql = octstr_format("CREATE TABLE IF NOT EXISTS %S (sql_id bigint(20) not null auto_increment primary key, momt enum('MO', 'MT') null, sender varchar(20) null, receiver varchar(20) null, udhdata blob null, msgdata text null, time bigint(20) null, smsc_id varchar(255) null, service varchar(255) null, account varchar(255) null, id bigint(20) null, sms_type bigint(20) null, mclass bigint(20) null, mwi bigint(20) null, coding bigint(20) null, compress bigint(20) null, validity bigint(20) null, deferred bigint(20) null, 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)", sqlbox_insert_table);
--- sqlbox_pgsql.c.orig 2006-05-18 22:03:09.000000000 -0600
+++ sqlbox_pgsql.c 2006-05-18 22:01:28.000000000 -0600
@@ -154,7 +154,7 @@
}
/* create send_sms && sent_sms tables if they do not exist */
- sql = octstr_format("CREATE TABLE IF NOT EXISTS %S (sql_id bigint(20) not null auto_increment primary key, momt enum('MO', 'MT') null, sender varchar(20) null, receiver varchar(20) null, udhdata varchar(255) null, msgdata varchar(255) null, time bigint(20) null, smsc_id varchar(255) null, service varchar(255) null, account varchar(255) null, id bigint(20) null, sms_type bigint(20) null, mclass bigint(20) null, mwi bigint(20) null, coding bigint(20) null, compress bigint(20) null, validity bigint(20) null, deferred bigint(20) null, 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)", sqlbox_logtable);
+ sql = octstr_format("CREATE TABLE IF NOT EXISTS %S (sql_id bigint(20) not null auto_increment primary key, momt enum('MO', 'MT', 'DLR') null, sender varchar(20) null, receiver varchar(20) null, udhdata varchar(255) null, msgdata varchar(255) null, time bigint(20) null, smsc_id varchar(255) null, service varchar(255) null, account varchar(255) null, id bigint(20) null, sms_type bigint(20) null, mclass bigint(20) null, mwi bigint(20) null, coding bigint(20) null, compress bigint(20) null, validity bigint(20) null, deferred bigint(20) null, 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)", sqlbox_logtable);
sql_update(sql);
octstr_destroy(sql);
sql = octstr_format("CREATE TABLE IF NOT EXISTS %S (sql_id bigint(20) not null auto_increment primary key, momt enum('MO', 'MT') null, sender varchar(20) null, receiver varchar(20) null, udhdata varchar(255) null, msgdata varchar(255) null, time bigint(20) null, smsc_id varchar(255) null, service varchar(255) null, account varchar(255) null, id bigint(20) null, sms_type bigint(20) null, mclass bigint(20) null, mwi bigint(20) null, coding bigint(20) null, compress bigint(20) null, validity bigint(20) null, deferred bigint(20) null, 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)", sqlbox_insert_table);