sizeof(struct usersupp) : cdbus->len));
cdb_free(cdbus);
- if (usbuf->version < 573) {
- CC->usersupp.moderation_filter = config.c_default_filter;
- }
return (0);
}
sizeof(struct visit) : cdbvisit->len));
cdb_free(cdbvisit);
}
+ else {
+ /* If this is the first time the user has seen this room,
+ * set the view to be the default for the room.
+ */
+ vbuf->v_view = rel_room->QRdefaultview;
+ }
/* Set v_seen if necessary */
if (vbuf->v_seen[0] == 0) {
PerformSessionHooks(EVT_LOGIN);
/* Create any personal rooms required by the system */
- create_room(SENTITEMS, 4, "", 0, 1);
+ create_room(SENTITEMS, 4, "", 0, 1, 0);
/* Enter the lobby */
usergoto(BASEROOM, 0, NULL, NULL);
usbuf.USscreenwidth = 80;
usbuf.USscreenheight = 24;
usbuf.lastcall = time(NULL);
- usbuf.moderation_filter = config.c_default_filter;
/* fetch a new user number */
usbuf.usernum = get_new_user_number();
/* add user to userlog */
putuser(&usbuf);
- /* give the user a private mailbox */
+ /* give the user a private mailbox and a configuration room */
MailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM);
- create_room(mailboxname, 5, "", 0, 1);
+ create_room(mailboxname, 5, "", 0, 1, 1);
+ MailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM);
+ create_room(mailboxname, 5, "", 0, 1, 1);
- /*** Everything below this line can be bypassed if we are administratively
- creating a user, instead of doing self-service account creation
- ***/
+ /* Everything below this line can be bypassed if administratively
+ creating a user, instead of doing self-service account creation
+ */
if (become_user) {
/* Now become the user we just created */
return;
getuser(&CC->usersupp, CC->curr_user);
- cprintf("%d %d|%d|%d|%d\n",
+ cprintf("%d %d|%d|%d|\n",
CIT_OK,
CC->usersupp.USscreenwidth,
CC->usersupp.USscreenheight,
- (CC->usersupp.flags & US_USER_SET),
- CC->usersupp.moderation_filter
+ (CC->usersupp.flags & US_USER_SET)
);
}
*/
void cmd_setu(char *new_parms)
{
- int new_mod;
-
if (CtdlAccessCheck(ac_logged_in))
return;
CC->usersupp.flags = CC->usersupp.flags |
(extract_int(new_parms, 2) & US_USER_SET);
- if (num_parms(new_parms) >= 4) {
- new_mod = extract_int(new_parms, 3);
- lprintf(9, "new_mod extracted to %d\n", new_mod);
-
- /* Aides cannot set the filter level lower than -100 */
- if (new_mod < (-100))
- new_mod = -100;
-
- /* Normal users cannot set the filter level lower than -63 */
- if ((new_mod < (-63)) && (CC->usersupp.axlevel < 6))
- new_mod = -63;
-
- /* Nobody can set the filter level higher than +63 */
- if (new_mod > 63)
- new_mod = 63;
-
- CC->usersupp.moderation_filter = new_mod;
- lprintf(9, "new_mod processed to %d\n", new_mod);
- }
lputuser(&CC->usersupp);
cprintf("%d Ok\n", CIT_OK);
}
}
+void cmd_gtsn(char *argbuf) {
+ char buf[SIZ];
+
+ if (CtdlAccessCheck(ac_logged_in)) {
+ return;
+ }
+
+ CtdlGetSeen(buf);
+ cprintf("%d %s\n", CIT_OK, buf);
+}
+
+
+
/*
* INVT and KICK commands
*/
}
/* check for mail */
- mail = NewMailCount();
+ mail = InitialMailCheck();
cprintf("%d %d|%d|%d\n", CIT_OK, mail, regis, vali);
}
}
+
+/*
+ * Check to see if the user who we just sent mail to is logged in. If yes,
+ * bump the 'new mail' counter for their session. That enables them to
+ * receive a new mail notification without having to hit the database.
+ */
+void BumpNewMailCounter(long which_user) {
+ struct CitContext *ptr;
+
+ begin_critical_section(S_SESSION_TABLE);
+
+ for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
+ if (ptr->usersupp.usernum == which_user) {
+ ptr->newmail += 1;
+ }
+ }
+
+ end_critical_section(S_SESSION_TABLE);
+}
+
+
/*
* Count the number of new mail messages the user has
*/
int NewMailCount()
{
int num_newmsgs = 0;
- int a;
- char mailboxname[ROOMNAMELEN];
- struct quickroom mailbox;
- struct visit vbuf;
- struct cdbdata *cdbfr;
- long *msglist = NULL;
- int num_msgs = 0;
- MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, MAILROOM);
- if (getroom(&mailbox, mailboxname) != 0)
- return (0);
- CtdlGetRelationship(&vbuf, &CC->usersupp, &mailbox);
-
- cdbfr = cdb_fetch(CDB_MSGLISTS, &mailbox.QRnumber, sizeof(long));
-
- if (cdbfr != NULL) {
- msglist = mallok(cdbfr->len);
- memcpy(msglist, cdbfr->ptr, cdbfr->len);
- num_msgs = cdbfr->len / sizeof(long);
- cdb_free(cdbfr);
- }
- if (num_msgs > 0)
- for (a = 0; a < num_msgs; ++a) {
- if (msglist[a] > 0L) {
- if (msglist[a] > vbuf.v_lastseen) {
- ++num_newmsgs;
- }
- }
- }
- if (msglist != NULL)
- phree(msglist);
+ num_newmsgs = CC->newmail;
+ CC->newmail = 0;
return (num_newmsgs);
}
+
+
+/*
+ * Count the number of new mail messages the user has
+ */
+int InitialMailCheck()
+{
+ int num_newmsgs = 0;
+ int a;
+ char mailboxname[ROOMNAMELEN];
+ struct quickroom mailbox;
+ struct visit vbuf;
+ struct cdbdata *cdbfr;
+ long *msglist = NULL;
+ int num_msgs = 0;
+
+ MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, MAILROOM);
+ if (getroom(&mailbox, mailboxname) != 0)
+ return (0);
+ CtdlGetRelationship(&vbuf, &CC->usersupp, &mailbox);
+
+ cdbfr = cdb_fetch(CDB_MSGLISTS, &mailbox.QRnumber, sizeof(long));
+
+ if (cdbfr != NULL) {
+ msglist = mallok(cdbfr->len);
+ memcpy(msglist, cdbfr->ptr, cdbfr->len);
+ num_msgs = cdbfr->len / sizeof(long);
+ cdb_free(cdbfr);
+ }
+ if (num_msgs > 0)
+ for (a = 0; a < num_msgs; ++a) {
+ if (msglist[a] > 0L) {
+ if (msglist[a] > vbuf.v_lastseen) {
+ ++num_newmsgs;
+ }
+ }
+ }
+ if (msglist != NULL)
+ phree(msglist);
+
+ return (num_newmsgs);
+}
+
+
+
+/*
+ * Set the preferred view for the current user/room combination
+ */
+void cmd_view(char *cmdbuf) {
+ int requested_view;
+ struct visit vbuf;
+
+ if (CtdlAccessCheck(ac_logged_in)) {
+ return;
+ }
+
+ requested_view = extract_int(cmdbuf, 0);
+
+ CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+ vbuf.v_view = requested_view;
+ CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+
+ cprintf("%d ok\n", CIT_OK);
+}