]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_whois.c
presence: m_presence module: Use safer get_metadata() where appropriate, to avoid...
[irc/rqf/shadowircd.git] / modules / m_whois.c
index ca8dc23848522c87cc16d17c43771469f30de822..a111e91887af464067b10757e311a14f5304e88a 100644 (file)
@@ -228,6 +228,7 @@ do_whois(struct Client *client_p, struct Client *source_p, int parc, const char
 static void
 single_whois(struct Client *source_p, struct Client *target_p, int operspy)
 {
+       const char *awaymsg;
        char buf[BUFSIZE];
        rb_dlink_node *ptr;
        struct membership *msptr;
@@ -239,6 +240,8 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
        hook_data_client hdata;
        int visible;
        int extra_space = 0;
+       struct DictionaryIter iter;
+       struct MetadataEntry *md;
 
        if(target_p->user == NULL)
        {
@@ -304,9 +307,9 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                           target_p->name, target_p->servptr->name,
                           target_p->servptr->info);
 
-       if(target_p->user->away)
+       if(!IsCapable(source_p, CLICAP_PRESENCE) && (awaymsg = get_metadata(target_p, "away")) != NULL)
                sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
-                                  target_p->name, target_p->user->away);
+                                  target_p->name, awaymsg);
 
        if(IsOper(target_p))
        {
@@ -366,6 +369,17 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
                }
        }
 
+       DICTIONARY_FOREACH(md, &iter, target_p->user->metadata)
+       {
+               /* XXX: hack around "away" for legacy clients. --nenolod */
+               if (!IsCapable(source_p, CLICAP_PRESENCE) && !irccmp(md->key, "away"))
+                       continue;
+
+               sendto_one_numeric(source_p, RPL_WHOISMETADATA,
+                                  form_str(RPL_WHOISMETADATA),
+                                  target_p->name, md->key, md->value);
+       }
+
        hdata.client = source_p;
        hdata.target = target_p;