From 8a2fbef2b9049783fc51d15bfeeda0199ae6162f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 12 Mar 2009 02:49:59 +0000 Subject: [PATCH] * Fixed problems related to saving vCards in config rooms. For starters, we were looking at the room name contained in the message rather than the name of the session's current room, which might actually be correct 100% of the time, but it's still the wrong place to look. We also needed to add code to distinguish between saving your own vCard and administratively saving someone else's vCard. We only reload the cs_inet_* caches when it's our own. --- citadel/modules/vcard/serv_vcard.c | 34 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 3539c43d4..30729d1f9 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -669,18 +669,28 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { long I; struct vCard *v; int is_UserConf=0; + int is_MY_UserConf=0; int is_GAB=0; + char roomname[ROOMNAMELEN]; + if (msg->cm_format_type != 4) return(0); if (!CC->logged_in) return(0); /* Only do this if logged in. */ - /* If this isn't the configuration room, or if this isn't a MIME - * message, don't bother. - */ - if (msg->cm_fields['O'] == NULL) return(0); - if (!strcasecmp(msg->cm_fields['O'], USERCONFIGROOM)) is_UserConf = 1; - if (!strcasecmp(msg->cm_fields['O'], ADDRESS_BOOK_ROOM)) is_GAB = 1; + /* We're interested in user config rooms only. */ + + if ( (strlen(CC->room.QRname) >= 12) && (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) { + is_UserConf = 1; /* It's someone's config room */ + } + MailboxName(roomname, sizeof roomname, &CC->user, USERCONFIGROOM); + if (!strcasecmp(CC->room.QRname, roomname)) { + is_UserConf = 1; + is_MY_UserConf = 1; /* It's MY config room */ + } + if (!strcasecmp(CC->room.QRname, ADDRESS_BOOK_ROOM)) { + is_GAB = 1; /* It's the Global Address Book */ + } + if (!is_UserConf && !is_GAB) return(0); - if (msg->cm_format_type != 4) return(0); ptr = msg->cm_fields['M']; if (ptr == NULL) return(0); @@ -700,12 +710,14 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { if (I < 0L) return(0); /* Store our Internet return address in memory */ - v = vcard_load(msg->cm_fields['M']); - extract_inet_email_addrs(CC->cs_inet_email, sizeof CC->cs_inet_email, + if (is_MY_UserConf) { + v = vcard_load(msg->cm_fields['M']); + extract_inet_email_addrs(CC->cs_inet_email, sizeof CC->cs_inet_email, CC->cs_inet_other_emails, sizeof CC->cs_inet_other_emails, v, 1); - extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v); - vcard_free(v); + extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v); + vcard_free(v); + } if (!is_GAB) { // This is not the GAB -- 2.30.2