1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fix last active query

This commit is contained in:
James Booth 2015-09-29 00:53:58 +01:00
parent 26d160cae8
commit bfdda17b7f
2 changed files with 5 additions and 12 deletions

View File

@ -743,9 +743,9 @@ sv_ev_lastactivity_response(const char * const from, const int seconds, const ch
// full jid or bare jid // full jid or bare jid
if (jidp->resourcepart || jidp->localpart) { if (jidp->resourcepart || jidp->localpart) {
if (msg) { 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 { } else {
cons_show("%s last active %d", from, seconds); cons_show("%s last active %d seconds ago.", from, seconds);
} }
// domain only // domain only

View File

@ -1091,18 +1091,9 @@ static int
_last_activity_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, _last_activity_get_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
void * const userdata) 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); 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) { if (from) {
int idls_secs = ui_get_idle_time() / 1000; int idls_secs = ui_get_idle_time() / 1000;
char str[50]; 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_set_type(response, STANZA_TYPE_RESULT);
xmpp_stanza_t *query = xmpp_stanza_new(ctx); 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, STANZA_ATTR_XMLNS, "jabber:iq:last");
xmpp_stanza_set_attribute(query, "seconds", str); xmpp_stanza_set_attribute(query, "seconds", str);
xmpp_stanza_add_child(response, query); xmpp_stanza_add_child(response, query);
xmpp_send(conn, response); xmpp_send(conn, response);
xmpp_stanza_release(query); xmpp_stanza_release(query);