At login time, copy prefer email addresses for user to the cs_inet_email fields in...
authorArt Cancro <ajc@citadel.org>
Fri, 19 May 2017 19:41:33 +0000 (15:41 -0400)
committerArt Cancro <ajc@citadel.org>
Fri, 19 May 2017 19:41:33 +0000 (15:41 -0400)
citadel/context.h
citadel/modules/upgrade/serv_upgrade.c
citadel/modules/vcard/serv_vcard.c
citadel/user_ops.c

index 76d2a91911a4d6e70b498ba68b6a8c6c78787884..744fcb6001f5bb19ead336859d95f479a228808d 100644 (file)
@@ -43,7 +43,7 @@ typedef struct CitContext CitContext;
  * Here's the big one... the Citadel context structure.
  *
  * This structure keeps track of all information relating to a running 
- * session on the server.  We keep one of these for each session thread.
+ * session on the server.  We keep one of these for each session.
  *
  */
 struct CitContext {
@@ -52,7 +52,7 @@ struct CitContext {
 
        int cs_pid;             /* session ID */
        int dont_term;          /* for special activities like artv so we don't get killed */
-       double created;      /* time of birth */
+       double created;         /* time of birth */
        time_t lastcmd;         /* time of last command executed */
        time_t lastidle;        /* For computing idle time */
        CCState state;          /* thread state (see CON_ values below) */
index 84e7f28329e3c50ba8a9281eb45bc60ec71d1299..e07de5b9fb1a86a916e99ed451fa8b36f03781a0 100644 (file)
@@ -507,7 +507,6 @@ void move_inet_addrs_from_vcards_to_user_records(void)
        ForEachUser(miafvtur_backend, NULL);
        miafvtur_backend(NULL, NULL);
        CtdlRebuildDirectoryIndex();
-       abort();
 }
 
 
index 1a30a86babdda0024aca345c35f82b4cc764aa47..89960d2230172a7f183c2c595b71d01b7e04e8bf 100644 (file)
@@ -477,12 +477,9 @@ int vcard_upload_aftersave(struct CtdlMessage *msg, recptypes *recp) {
                        I = atol(msg->cm_fields[eVltMsgNum]);
                        if (I <= 0L) return(0);
 
-                       /* Store our Internet return address in memory */
+                       /* Store our friendly/display name in memory */
                        if (is_MY_UserConf) {
                                v = vcard_load(msg->cm_fields[eMesageText]);
-                               extract_inet_email_addrs(CCC->cs_inet_email, sizeof CCC->cs_inet_email,
-                                               CCC->cs_inet_other_emails, sizeof CCC->cs_inet_other_emails,
-                                               v, 1);
                                extract_friendly_name(CCC->cs_inet_fn, sizeof CCC->cs_inet_fn, v);
                                vcard_free(v);
                        }
@@ -968,6 +965,7 @@ void cmd_gvsn(char *argbuf)
 
 /*
  * Get Valid Email Addresses
+ * FIXME this doesn't belong in serv_vcard.c anymore , maybe move it to internet_addressing.c
  */
 void cmd_gvea(char *argbuf)
 {
@@ -993,8 +991,6 @@ void cmd_gvea(char *argbuf)
 }
 
 
-
-
 /*
  * Callback function for cmd_dvca() that hunts for vCard content types
  * and outputs any email addresses found within.
@@ -1206,15 +1202,11 @@ void vcard_session_login_hook(void) {
 #endif
 
        /*
-        * Extract from the user's vCard, any Internet email addresses and the user's real name.
+        * Extract the user's friendly/screen name
         * These are inserted into the session data for various message entry commands to use.
         */
        v = vcard_get_user(&CCC->user);
        if (v) {
-               extract_inet_email_addrs(CCC->cs_inet_email, sizeof CCC->cs_inet_email,
-                                       CCC->cs_inet_other_emails, sizeof CCC->cs_inet_other_emails,
-                                       v, 1
-               );
                extract_friendly_name(CCC->cs_inet_fn, sizeof CCC->cs_inet_fn, v);
                vcard_free(v);
        }
index e19f238b0359fddac35def6586ae2dca5bd98cd1..7cff90d024847cdfc1292efd8278707d7c2553d6 100644 (file)
@@ -666,13 +666,24 @@ void do_login(void)
        CtdlPutUserLock(&CCC->user);
 
        /*
-        * Populate CCC->cs_inet_email with a default address.  This will be
-        * overwritten with the user's directory address, if one exists, when
-        * the vCard module's login hook runs.
+        * No email address for user?  Make one up.
         */
-       snprintf(CCC->cs_inet_email, sizeof CCC->cs_inet_email, "%s@%s",
-               CCC->user.fullname, CtdlGetConfigStr("c_fqdn"));
-       convert_spaces_to_underscores(CCC->cs_inet_email);
+       if (IsEmptyStr(CCC->user.emailaddrs)) {
+               sprintf(CCC->user.emailaddrs, "cit%ld@%s", CCC->user.usernum, CtdlGetConfigStr("c_fqdn"));
+       }
+       
+       /*
+        * Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record
+        */
+       strcpy(CCC->cs_inet_email, CCC->user.emailaddrs);
+       char *firstsep = strstr(CCC->cs_inet_email, "|");
+       if (firstsep) {
+               strcpy(CCC->cs_inet_other_emails, firstsep+1);
+               *firstsep = 0;
+       }
+       else {
+               CCC->cs_inet_other_emails[0] = 0;
+       }
 
        /* Create any personal rooms required by the system.
         * (Technically, MAILROOM should be there already, but just in case...)