From b4166762f14b4d28f4368dd1450eeec27164f9b8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 19 May 2017 15:41:33 -0400 Subject: [PATCH] At login time, copy prefer email addresses for user to the cs_inet_email fields in the context record --- citadel/context.h | 4 ++-- citadel/modules/upgrade/serv_upgrade.c | 1 - citadel/modules/vcard/serv_vcard.c | 14 +++----------- citadel/user_ops.c | 23 +++++++++++++++++------ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/citadel/context.h b/citadel/context.h index 76d2a9191..744fcb600 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -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) */ diff --git a/citadel/modules/upgrade/serv_upgrade.c b/citadel/modules/upgrade/serv_upgrade.c index 84e7f2832..e07de5b9f 100644 --- a/citadel/modules/upgrade/serv_upgrade.c +++ b/citadel/modules/upgrade/serv_upgrade.c @@ -507,7 +507,6 @@ void move_inet_addrs_from_vcards_to_user_records(void) ForEachUser(miafvtur_backend, NULL); miafvtur_backend(NULL, NULL); CtdlRebuildDirectoryIndex(); - abort(); } diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 1a30a86ba..89960d223 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -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); } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index e19f238b0..7cff90d02 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -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...) -- 2.30.2