]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6281 --resolve mod_rayo timestamp presence events
authorChris Rienzo <chris@rienzo.com>
Tue, 11 Mar 2014 00:10:18 +0000 (20:10 -0400)
committerChris Rienzo <chris@rienzo.com>
Tue, 11 Mar 2014 00:10:49 +0000 (20:10 -0400)
src/mod/event_handlers/mod_rayo/mod_rayo.c

index d20e31955d6e36fa8602789e4933ca6b7e14e92e..72e6e61bd957fe6aab6b671f9f6c1d3801a93ecf 100644 (file)
@@ -763,6 +763,7 @@ static void stop_deliver_message_threads(void)
  */
 void rayo_message_send(struct rayo_actor *from, const char *to, iks *payload, int dup, int reply, const char *file, int line)
 {
+       const char *msg_name;
        struct rayo_message *msg = malloc(sizeof(*msg));
        if (dup) {
                msg->payload = iks_copy(payload);
@@ -783,6 +784,21 @@ void rayo_message_send(struct rayo_actor *from, const char *to, iks *payload, in
        msg->file = strdup(file);
        msg->line = line;
 
+       /* add timestamp to presence events */
+       msg_name = iks_name(msg->payload);
+       if (!zstr(msg_name) && !strcmp("presence", msg_name)) {
+               iks *delay = iks_insert(msg->payload, "delay");
+               switch_time_exp_t tm;
+               char timestamp[80];
+               switch_size_t retsize;
+
+               iks_insert_attrib(delay, "xmlns", "urn:xmpp:delay");
+
+               switch_time_exp_tz(&tm, switch_time_now(), 0);
+               switch_strftime_nocheck(timestamp, &retsize, sizeof(timestamp), "%Y-%m-%dT%TZ", &tm);
+               iks_insert_attrib_printf(delay, "stamp", "%s", timestamp);
+       }
+
        if (switch_queue_trypush(globals.msg_queue, msg) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "failed to queue message!\n");
                rayo_message_destroy(msg);