modules/code/m_metadata: Changed to conform to IRCv3 command spec
This commit is contained in:
parent
be2a7a772c
commit
5810ebb18f
|
@ -30,6 +30,11 @@ mapi_clist_av1 metadata_clist[] = {
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(metadata, NULL, NULL, metadata_clist, NULL, NULL, "$Revision$");
|
DECLARE_MODULE_AV1(metadata, NULL, NULL, metadata_clist, NULL, NULL, "$Revision$");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Follows the specification for IRCv3 METADATA
|
||||||
|
* http://ircv3.org/specification/metadata-3.2
|
||||||
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
me_metadata(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
me_metadata(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
|
@ -40,9 +45,9 @@ me_metadata(struct Client *client_p, struct Client *source_p, int parc, const ch
|
||||||
if((chptr = find_channel(parv[2])) == NULL)
|
if((chptr = find_channel(parv[2])) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(!strcmp(parv[1], "ADD") && parv[4] != NULL)
|
if(!strcmp(parv[1], "SET") && parv[4] != NULL)
|
||||||
channel_metadata_add(chptr, parv[3], parv[4], 0);
|
channel_metadata_add(chptr, parv[3], parv[4], 0);
|
||||||
if(!strcmp(parv[1], "DELETE") && parv[3] != NULL)
|
if(!strcmp(parv[1], "CLEAR") && parv[3] != NULL)
|
||||||
channel_metadata_delete(chptr, parv[3], 0);
|
channel_metadata_delete(chptr, parv[3], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +61,9 @@ me_metadata(struct Client *client_p, struct Client *source_p, int parc, const ch
|
||||||
if(!target_p->user)
|
if(!target_p->user)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(!strcmp(parv[1], "ADD") && parv[4] != NULL)
|
if(!strcmp(parv[1], "SET") && parv[4] != NULL)
|
||||||
user_metadata_add(target_p, parv[3], parv[4], 0);
|
user_metadata_add(target_p, parv[3], parv[4], 0);
|
||||||
if(!strcmp(parv[1], "DELETE") && parv[3] != NULL)
|
if(!strcmp(parv[1], "CLEAR") && parv[3] != NULL)
|
||||||
user_metadata_delete(target_p, parv[3], 0);
|
user_metadata_delete(target_p, parv[3], 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2110,7 +2110,7 @@ channel_metadata_add(struct Channel *target, const char *name, const char *value
|
||||||
irc_dictionary_add(target->metadata, md->name, md);
|
irc_dictionary_add(target->metadata, md->name, md);
|
||||||
|
|
||||||
if(propegate)
|
if(propegate)
|
||||||
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA ADD %s %s :%s",
|
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA SET %s %s :%s",
|
||||||
target->chname, name, value);
|
target->chname, name, value);
|
||||||
|
|
||||||
return md;
|
return md;
|
||||||
|
@ -2163,7 +2163,7 @@ channel_metadata_delete(struct Channel *target, const char *name, int propegate)
|
||||||
rb_free(md);
|
rb_free(md);
|
||||||
|
|
||||||
if(propegate)
|
if(propegate)
|
||||||
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA DELETE %s %s",
|
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA CLEAR %s %s",
|
||||||
target->chname, name);
|
target->chname, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1955,7 +1955,7 @@ user_metadata_add(struct Client *target, const char *name, const char *value, in
|
||||||
irc_dictionary_add(target->user->metadata, md->name, md);
|
irc_dictionary_add(target->user->metadata, md->name, md);
|
||||||
|
|
||||||
if(propegate)
|
if(propegate)
|
||||||
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA ADD %s %s :%s",
|
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA SET %s %s :%s",
|
||||||
target->id, name, value);
|
target->id, name, value);
|
||||||
|
|
||||||
return md;
|
return md;
|
||||||
|
@ -1983,7 +1983,7 @@ user_metadata_delete(struct Client *target, const char *name, int propegate)
|
||||||
rb_free(md);
|
rb_free(md);
|
||||||
|
|
||||||
if(propegate)
|
if(propegate)
|
||||||
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA DELETE %s %s",
|
sendto_match_servs(&me, "*", CAP_ENCAP, NOCAPS, "ENCAP * METADATA CLEAR %s %s",
|
||||||
target->id, name);
|
target->id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -598,7 +598,7 @@ burst_TS6(struct Client *client_p)
|
||||||
|
|
||||||
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata)
|
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata)
|
||||||
{
|
{
|
||||||
sendto_one(client_p, ":%s ENCAP * METADATA ADD %s %s :%s",
|
sendto_one(client_p, ":%s ENCAP * METADATA SET %s %s :%s",
|
||||||
use_id(&me), use_id(target_p), md->name, md->value);
|
use_id(&me), use_id(target_p), md->name, md->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ burst_TS6(struct Client *client_p)
|
||||||
{
|
{
|
||||||
/* don't bother bursting +J metadata */
|
/* don't bother bursting +J metadata */
|
||||||
if(!(md->name[0] == 'K'))
|
if(!(md->name[0] == 'K'))
|
||||||
sendto_one(client_p, ":%s ENCAP * METADATA ADD %s %s :%s",
|
sendto_one(client_p, ":%s ENCAP * METADATA SET %s %s :%s",
|
||||||
use_id(&me), chptr->chname, md->name, md->value);
|
use_id(&me), chptr->chname, md->name, md->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue