4 * Automaticalyl copies the contents of a "New User Greetings" room to the
5 * inbox of any new user upon account creation.
10 * Name of the New User Greetings room.
12 #define NEWUSERGREETINGS "New User Greetings"
23 #include <sys/types.h>
25 #if TIME_WITH_SYS_TIME
26 # include <sys/time.h>
30 # include <sys/time.h>
41 #include "sysdep_decls.h"
42 #include "citserver.h"
45 #include "serv_extensions.h"
52 extern struct CitContext *ContextList;
56 * Copy the contents of the New User Greetings> room to the user's Mail> room.
58 void CopyNewUserGreetings(void) {
59 struct cdbdata *cdbfr;
62 char mailboxname[ROOMNAMELEN];
65 /* Only do this for new users. */
66 if (CC->user.timescalled != 1) return;
68 /* This user's mailbox. */
69 MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
71 /* Go to the source room ... bail out silently if it's not there,
72 * or if it's not private.
74 if (getroom(&CC->room, NEWUSERGREETINGS) != 0) return;
75 if (! CC->room.QRflags & QR_PRIVATE ) return;
77 cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
80 msglist = malloc(cdbfr->len);
81 memcpy(msglist, cdbfr->ptr, cdbfr->len);
82 num_msgs = cdbfr->len / sizeof(long);
87 CtdlCopyMsgsToRoom(msglist, num_msgs, mailboxname);
90 /* Now free the memory we used, and go away. */
91 if (msglist != NULL) free(msglist);
95 char *serv_newuser_init(void)
97 CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);