From 9779faf1053f65d3c1bca333bf3deabcd185701d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 4 Feb 2014 19:21:29 -0500 Subject: [PATCH] Finished the GROUP command --- citadel/modules/nntp/serv_nntp.c | 51 +++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/citadel/modules/nntp/serv_nntp.c b/citadel/modules/nntp/serv_nntp.c index 094475ed4..fe861374c 100644 --- a/citadel/modules/nntp/serv_nntp.c +++ b/citadel/modules/nntp/serv_nntp.c @@ -563,10 +563,54 @@ void nntp_group(const char *cmd) { char requested_group[1024]; char requested_room[ROOMNAMELEN]; + char augmented_roomname[ROOMNAMELEN]; + int c = 0; + int ok = 0; + int ra = 0; + struct ctdlroom QRscratch; + int msgs, new; + long oldest,newest; + extract_token(requested_group, cmd, 1, ' ', sizeof requested_group); newsgroup_to_room(requested_room, requested_group, sizeof requested_room); - cprintf("599 FIXME screw you and your %s\r\n", requested_room); + /* First try a regular match */ + c = CtdlGetRoom(&QRscratch, requested_room); + + /* Then try a mailbox name match */ + if (c != 0) { + CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, requested_room); + c = CtdlGetRoom(&QRscratch, augmented_roomname); + if (c == 0) { + safestrncpy(requested_room, augmented_roomname, sizeof(requested_room)); + } + } + + /* If the room exists, check security/access */ + if (c == 0) { + /* See if there is an existing user/room relationship */ + CtdlRoomAccess(&QRscratch, &CC->user, &ra, NULL); + + /* normal clients have to pass through security */ + if (ra & UA_KNOWN) { + ok = 1; + } + } + + /* Fail here if no such room */ + if (!ok) { + cprintf("411 no such newsgroup\r\n"); + return; + } + + + /* + * CtdlUserGoto() formally takes us to the desired room, happily returning + * the number of messages and number of new messages. + */ + memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom)); + CtdlUserGoto(NULL, 0, 0, &msgs, &new, &oldest, &newest); + cprintf("211 %d %ld %ld %s\r\n", msgs, oldest, newest, requested_group); } @@ -679,3 +723,8 @@ CTDL_MODULE_INIT(nntp) return "nntp"; } + + + + + -- 2.30.2