about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-09-29 00:53:58 +0100
committerJames Booth <boothj5@gmail.com>2015-09-29 00:53:58 +0100
commitbfdda17b7f5047100da7c9d0050cad487b037a0e (patch)
treef83f1ddfe6bc6e2a1c4bd01c4b77923fee982d91 /src
parent26d160cae861865191150c73853a748fcd9cfad1 (diff)
downloadprofani-tty-bfdda17b7f5047100da7c9d0050cad487b037a0e.tar.gz
Fix last active query
Diffstat (limited to 'src')
-rw-r--r--src/event/server_events.c4
-rw-r--r--src/xmpp/iq.c13
2 files changed, 5 insertions, 12 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 7b24f6b9..ea181865 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -743,9 +743,9 @@ sv_ev_lastactivity_response(const char * const from, const int seconds, const ch
     // full jid or bare jid
     if (jidp->resourcepart || jidp->localpart) {
         if (msg) {
-            cons_show("%s last active %d, status: %s", from, seconds, msg);
+            cons_show("%s last active %d seconds ago, status: %s", from, seconds, msg);
         } else {
-            cons_show("%s last active %d", from, seconds);
+            cons_show("%s last active %d seconds ago.", from, seconds);
         }
 
     // domain only
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 29aa0944..8796cf0b 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1091,18 +1091,9 @@ static int
 _last_activity_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     void * const userdata)
 {
-    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
+    xmpp_ctx_t *ctx = connection_get_ctx();
     const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
 
-    /*
-<iq from='juliet@capulet.com/balcony'
-    id='last2'
-    to='romeo@montague.net/orchard'
-    type='result'>
-  <query xmlns='jabber:iq:last' seconds='123'/>
-</iq>
-     */
-
     if (from) {
         int idls_secs = ui_get_idle_time() / 1000;
         char str[50];
@@ -1115,10 +1106,12 @@ _last_activity_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz
         xmpp_stanza_set_type(response, STANZA_TYPE_RESULT);
 
         xmpp_stanza_t *query = xmpp_stanza_new(ctx);
+        xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
         xmpp_stanza_set_attribute(query, STANZA_ATTR_XMLNS, "jabber:iq:last");
         xmpp_stanza_set_attribute(query, "seconds", str);
 
         xmpp_stanza_add_child(response, query);
+
         xmpp_send(conn, response);
 
         xmpp_stanza_release(query);