summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2013-05-16 09:57:59 +0200
committerYorhel <git@yorhel.nl>2013-05-16 09:57:59 +0200
commitb60066e534e523153db7fdd50a99afdc1637a559 (patch)
tree0bdae31c9078df80d6692be4d25ac75f93d9fab3
parentb7cc09716ee4e46aefe077f821adfed0d7d98c23 (diff)
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)
-rw-r--r--src/hub/nmdc.c11
1 files 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;