From: Art Cancro Date: Mon, 25 Nov 2019 04:45:05 +0000 (-0500) Subject: The user principal identity is now used as the JID in all XMPP protocol stanzas. X-Git-Tag: v939~257 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1ab27069271df6ed100343866c93c0ef2eb2a888 The user principal identity is now used as the JID in all XMPP protocol stanzas. --- diff --git a/citadel/context.h b/citadel/context.h index 95fa16d90..e76d7acb0 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -91,6 +91,7 @@ struct CitContext { char cs_addr[64]; /* address logged in from */ /* The Internet type of thing */ + char cs_principal_id[256]; /* User principal identity for XMPP, ActivityPub, etc. */ char cs_inet_email[128]; /* Return address of outbound Internet mail */ char cs_inet_other_emails[1024]; /* User's other valid Internet email addresses */ char cs_inet_fn[128]; /* Friendly-name of outbound Internet mail */ diff --git a/citadel/modules/instmsg/serv_instmsg.c b/citadel/modules/instmsg/serv_instmsg.c index dfa16cc68..fad00f0ef 100644 --- a/citadel/modules/instmsg/serv_instmsg.c +++ b/citadel/modules/instmsg/serv_instmsg.c @@ -294,7 +294,7 @@ void cmd_sexp(char *argbuf) return; } - lem = CC->cs_inet_email; + lem = CC->cs_principal_id; extract_token(x_user, argbuf, 0, '|', sizeof x_user); extract_token(x_msg, argbuf, 1, '|', sizeof x_msg); diff --git a/citadel/modules/xmpp/serv_xmpp.c b/citadel/modules/xmpp/serv_xmpp.c index c2d498ba4..84aa4ba38 100644 --- a/citadel/modules/xmpp/serv_xmpp.c +++ b/citadel/modules/xmpp/serv_xmpp.c @@ -420,7 +420,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) { } /* Generate the "full JID" of the client (user@host/resource) */ - snprintf(XMPP->client_jid, sizeof XMPP->client_jid, "%s/%s", CC->cs_inet_email, XMPP->iq_client_resource); + snprintf(XMPP->client_jid, sizeof XMPP->client_jid, "%s/%s", CC->cs_principal_id, XMPP->iq_client_resource); /* Tell the client what its JID is */ cprintf("", xmlesc(xmlbuf, XMPP->iq_id, sizeof xmlbuf)); @@ -649,7 +649,7 @@ void xmpp_async_loop(void) { * Login hook for XMPP sessions */ void xmpp_login_hook(void) { - xmpp_queue_event(XMPP_EVT_LOGIN, CC->cs_inet_email); + xmpp_queue_event(XMPP_EVT_LOGIN, CC->cs_principal_id); } @@ -657,7 +657,7 @@ void xmpp_login_hook(void) { * Logout hook for XMPP sessions */ void xmpp_logout_hook(void) { - xmpp_queue_event(XMPP_EVT_LOGOUT, CC->cs_inet_email); + xmpp_queue_event(XMPP_EVT_LOGOUT, CC->cs_principal_id); } diff --git a/citadel/modules/xmpp/xmpp_messages.c b/citadel/modules/xmpp/xmpp_messages.c index 90e09e281..3a114273a 100644 --- a/citadel/modules/xmpp/xmpp_messages.c +++ b/citadel/modules/xmpp/xmpp_messages.c @@ -97,14 +97,14 @@ void xmpp_send_message(char *message_to, char *message_body) { for (cptr = ContextList; cptr != NULL; cptr = cptr->next) { if ( (cptr->logged_in) && (cptr->can_receive_im) - && (!strcasecmp(cptr->cs_inet_email, message_to)) + && (!strcasecmp(cptr->cs_principal_id, message_to)) ) { recp = cptr->user.fullname; } } if (recp) { - PerformXmsgHooks(CC->user.fullname, CC->cs_inet_email, recp, message_body); + PerformXmsgHooks(CC->user.fullname, CC->cs_principal_id, recp, message_body); } free(XMPP->message_body); diff --git a/citadel/modules/xmpp/xmpp_presence.c b/citadel/modules/xmpp/xmpp_presence.c index 4f71c7eea..8fa6dea7f 100644 --- a/citadel/modules/xmpp/xmpp_presence.c +++ b/citadel/modules/xmpp/xmpp_presence.c @@ -106,7 +106,7 @@ void xmpp_wholist_presence_dump(void) for (i=0; i", - xmlesc(xmlbuf1, CC->cs_inet_email, sizeof xmlbuf1), + xmlesc(xmlbuf1, CC->cs_principal_id, sizeof xmlbuf1), xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2), ++unsolicited_id ); @@ -184,7 +184,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) { /* Count the visible sessions for this user */ for (i=0; i", - xmlesc(xmlbuf1, cptr->cs_inet_email, sizeof xmlbuf1), + xmlesc(xmlbuf1, cptr->cs_principal_id, sizeof xmlbuf1), xmlesc(xmlbuf2, cptr->user.fullname, sizeof xmlbuf2) ); cprintf("%s", xmlesc(xmlbuf1, CtdlGetConfigStr("c_humannode"), sizeof xmlbuf1)); diff --git a/citadel/user_ops.c b/citadel/user_ops.c index c215e734a..0507fc6ba 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -697,6 +697,12 @@ void do_login(void) AutoGenerateEmailAddressForUser(&CC->user); } + /* Populate the user principal identity, which is consistent and never aliased */ + strcpy(CC->cs_principal_id, "wowowowow"); + makeuserkey(CC->cs_principal_id, CC->user.fullname, sizeof CC->user.fullname); + strcat(CC->cs_principal_id, "@"); + strcat(CC->cs_principal_id, CtdlGetConfigStr("c_fqdn")); + /* * Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record */