From a9ce04fb8700d223a9735d55de4ae858acd56b6d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 5 Nov 1999 03:57:11 +0000 Subject: [PATCH] * Issue 'cancel' messages for vCard when a user is deleted. * Try to delete 'cancel' messages locally after they've been distributed. --- citadel/ChangeLog | 5 ++++ citadel/msgbase.c | 2 +- citadel/netproc.c | 55 ++++++++++++++++++++++++++++++++++++++++ citadel/serv_vcard.c | 42 +++++++++++++++++++++++++++++- citadel/techdoc/hack.txt | 7 +++-- 5 files changed, 107 insertions(+), 4 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 38bacd21c..a2cbe4477 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.412 1999/11/05 03:53:47 ajc +* Issue 'cancel' messages for vCard when a user is deleted. +* Try to delete 'cancel' messages locally after they've been distributed. + Revision 1.411 1999/11/03 04:01:20 ajc * Fixed buffer overrun problems in cmd_rchg(), cmd_hchg(), and cmd_uchg() * Removed my email address as the feedback content from the docs; replaced @@ -1422,3 +1426,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/msgbase.c b/citadel/msgbase.c index b5b41e82c..7c18b943c 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -56,7 +56,7 @@ char *msgkeys[] = { "path", "", "rcpt", - "", + "spec", "time", "subj", "", diff --git a/citadel/netproc.c b/citadel/netproc.c index 65c213090..5f6fc197b 100644 --- a/citadel/netproc.c +++ b/citadel/netproc.c @@ -90,6 +90,7 @@ void get_config(void); struct filterlist *filter = NULL; struct syslist *slist = NULL; +struct msglist *purgelist = NULL; struct config config; extern char bbs_home_directory[]; @@ -1177,6 +1178,54 @@ int ismsgok(FILE *mmfp, char *sysname) + +/* + * Add a message to the list of messages to be deleted off the local server + * at the end of this run. + */ +void delete_locally(long msgid, char *roomname) { + struct msglist *mptr; + + mptr = (struct msglist *) malloc(sizeof(struct msglist)); + mptr->next = purgelist; + mptr->m_num = msgid; + strcpy(mptr->m_rmname, roomname); + purgelist = mptr; +} + + + +/* + * Delete all messages on the purge list from the local server. + */ +void process_purgelist(void) { + char curr_rm[ROOMNAMELEN]; + char buf[256]; + struct msglist *mptr; + + + strcpy(curr_rm, "__nothing__"); + while (purgelist != NULL) { + if (strcasecmp(curr_rm, purgelist->m_rmname)) { + sprintf(buf, "GOTO %s", purgelist->m_rmname); + serv_puts(buf); + serv_gets(buf); + if (buf[0] == '2') extract(curr_rm, &buf[4], 0); + } + if (strcasecmp(curr_rm, purgelist->m_rmname)) { + sprintf(buf, "DELE %ld", purgelist->m_num); + serv_puts(buf); + serv_gets(buf); + } + mptr = purgelist->next; + free(purgelist); + purgelist = mptr; + } +} + + + + /* spool list of messages to a file */ /* returns # of msgs spooled */ int spool_out(struct msglist *cmlist, FILE * destfp, char *sysname) @@ -1242,6 +1291,9 @@ int spool_out(struct msglist *cmlist, FILE * destfp, char *sysname) fprintf(destfp, "%s!", NODENAME); if (a != 'C') fwrite(fbuf, strlen(fbuf) + 1, 1, destfp); + if (a == 'S') if (!strcasecmp(fbuf, "CANCEL")) { + delete_locally(cmptr->m_num, cmptr->m_rmname); + } } if (a == 'M') { fprintf(destfp, "C%s%c", @@ -1529,6 +1581,9 @@ int main(int argc, char **argv) /* Update mail.sysinfo with new information we learned */ rewrite_syslist(); + /* Delete any messages which need to be purged locally */ + process_purgelist(); + /* Close the use table */ purge_use_table(use_table); gdbm_close(use_table); diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 40e7727f7..0ee76514c 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -379,13 +379,49 @@ void cmd_greg(char *argbuf) } +/* + * When a user is being deleted, we have to remove his/her vCard. + * This is accomplished by issuing a message with 'CANCEL' in the S (special) + * field, and the same Extended ID as the existing card. + */ +void vcard_purge(char *username, long usernum) { + struct CtdlMessage *msg; + char buf[256]; + + msg = (struct CtdlMessage *) mallok(sizeof(struct CtdlMessage)); + if (msg == NULL) return; + memset(msg, 0, sizeof(struct CtdlMessage)); + msg->cm_magic = CTDLMESSAGE_MAGIC; + msg->cm_anon_type = MES_NORMAL; + msg->cm_format_type = 0; + msg->cm_fields['A'] = strdoop(username); + msg->cm_fields['O'] = strdoop(ADDRESS_BOOK_ROOM); + msg->cm_fields['N'] = strdoop(NODENAME); + msg->cm_fields['M'] = strdoop("Purge this vCard\n"); + + sprintf(buf, + "Citadel vCard: personal card for %s at %s", + msg->cm_fields['A'], NODENAME); + msg->cm_fields['E'] = strdoop(buf); + + msg->cm_fields['S'] = strdoop("CANCEL"); + + CtdlSaveMsg(msg, "", ADDRESS_BOOK_ROOM, MES_LOCAL, 1); + CtdlFreeMessage(msg); +} + + + + +/* + * Session startup, allocate some per-session data + */ void vcard_session_startup_hook(void) { CtdlAllocUserData(SYM_VCARD, sizeof(struct vcard_internal_info)); } - char *Dynamic_Module_Init(void) { SYM_VCARD = CtdlGetDynamicSymbol(); @@ -394,6 +430,10 @@ char *Dynamic_Module_Init(void) CtdlRegisterMessageHook(vcard_upload_aftersave, EVT_AFTERSAVE); CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info"); CtdlRegisterProtoHook(cmd_greg, "GREG", "Get registration info"); + CtdlRegisterUserHook(vcard_purge, EVT_PURGEUSER); create_room(ADDRESS_BOOK_ROOM, 0, "", 0); return "$Id$"; } + + + diff --git a/citadel/techdoc/hack.txt b/citadel/techdoc/hack.txt index 889d56200..6218a80a4 100644 --- a/citadel/techdoc/hack.txt +++ b/citadel/techdoc/hack.txt @@ -112,8 +112,11 @@ S Special field Only meaningful for messages being spooled over a network. Usually means that the message isn't really a message, but rather some other network function: -> "S" followed by "FILE" (followed by a null, of - course) means that the message text is actually an - IGnet/Open file transfer. + course) means that the message text is actually an + IGnet/Open file transfer. + -> "S" followed by "CANCEL" means that this message + should be deleted from the local message base once + it has been replicated to all network systems. T Date/Time A 32-bit integer containing the date and time of the message in standard UNIX format (the number of seconds since January 1, 1970 GMT). -- 2.30.2