From b60066e534e523153db7fdd50a99afdc1637a559 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 16 May 2013 09:57:59 +0200 Subject: hub/nmdc: Add a few more is-user-really-online checks hub_users_get() may return something for offline users, so is, on its own, not suitable for checking whether a user is online or not. (This has always been the case, these bugs were present before a27137d) --- src/hub/nmdc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hub/nmdc.c b/src/hub/nmdc.c index 048348a..be0264f 100644 --- a/src/hub/nmdc.c +++ b/src/hub/nmdc.c @@ -280,7 +280,8 @@ static void hub_nmdc_hello(hub_t *h, const char *cmd, int len) { cmd_send(h, "$GetNickList|"); } - if(uid && !h->n.nogetinfo && !hub_users_get(h, uid)) + hub_user_t *u = hub_users_get(h, uid); + if(uid && !h->n.nogetinfo && (!u || !u->online)) cmd_send(h, "$GetINFO %.*s %s|", nicklen, nick, h->n.nick); } @@ -304,7 +305,8 @@ static void hub_nmdc_to(hub_t *h, const char *cmd, int len) { return; } int64_t group = hub_nmdc_userid(h, msg, l-1); - if(!hub_users_get(h, group)) + hub_user_t *u; + if(!(u = hub_users_get(h, group)) || !u->online) group = -1; msg += l+1; @@ -313,7 +315,7 @@ static void hub_nmdc_to(hub_t *h, const char *cmd, int len) { bool me; const char *off = nmdc_chat_parse(msg, &nick, &nicklen, &me); int64_t uid = !nick ? -1 : hub_nmdc_userid(h, nick, nicklen); - if(uid > 0 && !hub_users_get(h, uid)) { + if(uid > 0 && (!(u = hub_users_get(h, uid)) || !u->online)) { me = false; off = cmd; } @@ -521,7 +523,8 @@ static void hub_nmdc_mainchat(hub_t *h, const char *cmd, int len) { bool me; const char *off = nmdc_chat_parse(cmd, &nick, &nicklen, &me); int64_t uid = !nick ? -1 : hub_nmdc_userid(h, nick, nicklen); - if(uid > 0 && !hub_users_get(h, uid)) { + hub_user_t *u = hub_users_get(h, uid); + if(uid > 0 && (!u || !u->online)) { me = false; off = cmd; uid = -1; -- cgit v1.2.3