The user principal identity is now used as the JID in all XMPP protocol stanzas.
authorArt Cancro <ajc@citadel.org>
Mon, 25 Nov 2019 04:45:05 +0000 (23:45 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 25 Nov 2019 04:45:05 +0000 (23:45 -0500)
citadel/context.h
citadel/modules/instmsg/serv_instmsg.c
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/xmpp_messages.c
citadel/modules/xmpp/xmpp_presence.c
citadel/modules/xmpp/xmpp_query_namespace.c
citadel/user_ops.c

index 95fa16d90d70be27216ffbf55105807f9e531a78..e76d7acb024a3cf7d676c34b126eb7ef9db42b7d 100644 (file)
@@ -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 */
index dfa16cc689eb75ca34c3b51a2b2815b9cc433b40..fad00f0ef6c28492d5156b962f20492518477c13 100644 (file)
@@ -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);
index c2d498ba4580d1c4aa0abdae979582e82c9aa325..84aa4ba38bbdafee127706d2b3beead9c8443102 100644 (file)
@@ -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("<iq type=\"result\" id=\"%s\">", 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);
 }
 
 
index 90e09e281e0b7258ec78d4d320abd112e2b70093..3a114273ac94fee72a8398124d9ba9e01b5e6144 100644 (file)
@@ -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);
index 4f71c7eea9ed4dfcaffcc9d4ac6b7b6fd82aba06..8fa6dea7fa6e7cddbf577828ff8db7ed0b47fbbb 100644 (file)
@@ -106,7 +106,7 @@ void xmpp_wholist_presence_dump(void)
 
        for (i=0; i<nContexts; i++) {
                if (xmpp_is_visible(&cptr[i], CC)) {
-                       xmpp_indicate_presence(cptr[i].cs_inet_email);
+                       xmpp_indicate_presence(cptr[i].cs_principal_id);
                }
        }
        free(cptr);
@@ -149,7 +149,7 @@ void xmpp_destroy_buddy(char *presence_jid, int aggressively) {
 
        /* Do an unsolicited roster update that deletes the contact. */
        cprintf("<iq from=\"%s\" to=\"%s\" id=\"unbuddy_%x\" type=\"result\">",
-               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<nContexts; i++) {
-               if ( (!strcasecmp(cptr[i].cs_inet_email, presence_jid))
+               if ( (!strcasecmp(cptr[i].cs_principal_id, presence_jid))
                   && (xmpp_is_visible(&cptr[i], CC))
                )  {
                        ++visible_sessions;
@@ -330,7 +330,7 @@ void xmpp_massacre_roster(void)
                for (i=0; i<nContexts; i++) {
                        if (xmpp_is_visible(&cptr[i], CC)) {
                                if (mortuary) {
-                                       char *buddy = strdup(cptr[i].cs_inet_email);
+                                       char *buddy = strdup(cptr[i].cs_principal_id);
                                        Put(mortuary, buddy, strlen(buddy), buddy, NULL);
                                }
                        }
@@ -376,7 +376,7 @@ void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void)
                online_now = 0;
                if (cptr) for (i=0; i<nContexts; i++) {
                        if (xmpp_is_visible(&cptr[i], CC)) {
-                               if (!strcasecmp(cptr[i].cs_inet_email, (char *)Value)) {
+                               if (!strcasecmp(cptr[i].cs_principal_id, (char *)Value)) {
                                        online_now = 1;
                                }
                        }
index f221cc28a9f16a36db3015481388a819055c70a3..1b17b952f166ec0c5a3f544f08e033552ac73177 100644 (file)
@@ -57,7 +57,7 @@ void xmpp_roster_item(struct CitContext *cptr) {
        char xmlbuf2[256];
 
        cprintf("<item jid=\"%s\" name=\"%s\" subscription=\"both\">",
-               xmlesc(xmlbuf1, cptr->cs_inet_email, sizeof xmlbuf1),
+               xmlesc(xmlbuf1, cptr->cs_principal_id, sizeof xmlbuf1),
                xmlesc(xmlbuf2, cptr->user.fullname, sizeof xmlbuf2)
        );
        cprintf("<group>%s</group>", xmlesc(xmlbuf1, CtdlGetConfigStr("c_humannode"), sizeof xmlbuf1));
index c215e734a6706940472766ac502b366385868c4d..0507fc6baca99c4132d008d1f7f32bf91414addb 100644 (file)
@@ -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
         */