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;
63 char mailboxname[ROOMNAMELEN];
66 /* Only do this for new users. */
67 if (CC->user.timescalled != 1) return;
69 /* This user's mailbox. */
70 MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
72 /* Go to the source room ... bail out silently if it's not there,
73 * or if it's not private.
75 if (getroom(&CC->room, NEWUSERGREETINGS) != 0) return;
76 if (! CC->room.QRflags & QR_PRIVATE ) return;
78 cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
81 msglist = malloc(cdbfr->len);
82 memcpy(msglist, cdbfr->ptr, cdbfr->len);
83 num_msgs = cdbfr->len / sizeof(long);
88 for (i = 0; i < num_msgs; ++i) {
89 CtdlCopyMsgToRoom(msglist[i], mailboxname);
93 /* Now free the memory we used, and go away. */
94 if (msglist != NULL) free(msglist);
98 char *serv_newuser_init(void)
100 CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);