diff --git a/doc/technical/elemental-deviation.markdown b/doc/technical/elemental-deviation.markdown index 2217056..81d63ce 100644 --- a/doc/technical/elemental-deviation.markdown +++ b/doc/technical/elemental-deviation.markdown @@ -52,3 +52,17 @@ servers and check. Bots or pseudoservices may also uses these lines to perform additional actions (such as `AKILL`s or logging to channels) as needed by the bot author. +#### METADATA + +The old ShadowIRCD implementation of METADATA used `ADD` and `DELETE` verbs for +adding and deleting metadata to channels and clients. This, in practice looks +something like: + + <<< :45X ENCAP * METADATA ADD 1NRAAAABR OPERSTRING :is an IRC Administrator + <<< :45X ENCAP * METADATA DELETE 1NRAAAABR OPERSTRING + +Functionality is identical to the new `SET` and `CLEAR` verbs, but this deviates +from the spec by being **only** a server to server command. Support for client +to server and server to client metadata setting/getting will come in a future +version of elemental-ircd. + diff --git a/modules/core/m_metadata.c b/modules/core/m_metadata.c index 77fe0fe..47925de 100644 --- a/modules/core/m_metadata.c +++ b/modules/core/m_metadata.c @@ -30,6 +30,11 @@ mapi_clist_av1 metadata_clist[] = { 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 me_metadata(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { @@ -40,10 +45,17 @@ me_metadata(struct Client *client_p, struct Client *source_p, int parc, const ch if((chptr = find_channel(parv[2])) == NULL) return 0; + //XXX need to support the old, nonstandard verbs for compatability reasons if(!strcmp(parv[1], "ADD") && parv[4] != NULL) channel_metadata_add(chptr, parv[3], parv[4], 0); if(!strcmp(parv[1], "DELETE") && parv[3] != NULL) channel_metadata_delete(chptr, parv[3], 0); + + //Now moving on to the standard ones + if(!strcmp(parv[1], "SET") && parv[4] != NULL) + channel_metadata_add(chptr, parv[3], parv[4], 0); + if(!strcmp(parv[1], "CLEAR") && parv[3] != NULL) + channel_metadata_delete(chptr, parv[3], 0); } else @@ -56,10 +68,17 @@ me_metadata(struct Client *client_p, struct Client *source_p, int parc, const ch if(!target_p->user) return 0; + //XXX need to support the old, nonstandard verbs for compatability reasons if(!strcmp(parv[1], "ADD") && parv[4] != NULL) user_metadata_add(target_p, parv[3], parv[4], 0); if(!strcmp(parv[1], "DELETE") && parv[3] != NULL) user_metadata_delete(target_p, parv[3], 0); + + //Now moving on to the standard ones + if(!strcmp(parv[1], "SET") && parv[4] != NULL) + user_metadata_add(target_p, parv[3], parv[4], 0); + if(!strcmp(parv[1], "CLEAR") && parv[3] != NULL) + user_metadata_delete(target_p, parv[3], 0); } return 0; } diff --git a/src/channel.c b/src/channel.c index 44c1ba3..fdfa8ec 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2102,7 +2102,7 @@ channel_metadata_add(struct Channel *target, const char *name, const char *value irc_dictionary_add(target->metadata, md->name, md); 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); return md; @@ -2155,7 +2155,7 @@ channel_metadata_delete(struct Channel *target, const char *name, int propegate) rb_free(md); 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); } diff --git a/src/client.c b/src/client.c index cf95175..6f9abe9 100644 --- a/src/client.c +++ b/src/client.c @@ -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); 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); return md; @@ -1983,7 +1983,7 @@ user_metadata_delete(struct Client *target, const char *name, int propegate) rb_free(md); 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); } diff --git a/src/s_serv.c b/src/s_serv.c index 46fbcf0..e4576c6 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -598,7 +598,7 @@ burst_TS6(struct Client *client_p) 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); } @@ -666,7 +666,7 @@ burst_TS6(struct Client *client_p) { /* don't bother bursting +J metadata */ 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); }