diff src/noffle.c @ 192:b9ef99708d1c noffle

[svn] * docs/noffle.conf.5,src/noffle.c: Duh! Do unsubscribing the simple way. Auto-unsubscribe when the last access time is more than the threshold number of days behind the time the last article arrived.
author bears
date Sun, 21 Oct 2001 12:00:12 +0100
parents 28488e0e3630
children 61a0f1e13916
line wrap: on
line diff
--- a/src/noffle.c	Sat Oct 20 14:23:46 2001 +0100
+++ b/src/noffle.c	Sun Oct 21 12:00:12 2001 +0100
@@ -10,7 +10,7 @@
   received for some seconds (to allow multiple clients connect at the same
   time).
 
-  $Id: noffle.c 310 2001-10-20 13:23:46Z bears $
+  $Id: noffle.c 311 2001-10-21 11:00:12Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -237,7 +237,7 @@
     Str grp;
     Bool autoUnsubscribe;
     int autoUnsubscribeDays;
-    time_t now = time( NULL ), maxAge = 0;
+    time_t maxAge = 0;
     const char *msgId;
 
     autoUnsubscribe = Cfg_autoUnsubscribe();
@@ -267,30 +267,25 @@
                     else
                         ++cntLeft;
                 }
+
+	    /*
+	     * Auto unsubscribe where applicable if last article arrival
+	     * time is maxAge newer than the last access time. This ensures
+	     * the low traffic groups don't get expired simply because
+	     * there's been nothing to read.
+	     */
             if ( ! Grp_local( grp )
                  && Fetchlist_contains( grp )
                  && autoUnsubscribe
-                 && difftime( now, Grp_lastAccess( grp ) ) > maxAge )
+                 && difftime( Grp_lastPostTime(grp),
+			      Grp_lastAccess( grp ) ) > maxAge )
             {
-		/* If there have been recent posts, unsubscribe. */
-		if ( difftime( now, Grp_lastPostTime( grp ) ) <= maxAge )
-		{
-		    Log_ntc( "Auto-unsubscribing from %s after %d "
-			     "days without access",
-			     grp, autoUnsubscribeDays );
-		    Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays );
-		    Fetchlist_remove( grp );
-		    Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED );
-		}
-		else
-		{
-		    /*
-		     * Otherwise if no recent posts touch the access.
-		     * This way we don't unsubscribe to low volume groups
-		     * unread only because there are no recent posts.
-		     */
-		    Grp_setLastAccess( grp );		    
-		}
+		Log_ntc( "Auto-unsubscribing from %s after %d "
+			 "days without access",
+			 grp, autoUnsubscribeDays );
+		Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays );
+		Fetchlist_remove( grp );
+		Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED );
             }
             Cont_write();
             Grp_setFirstLast( grp, Cont_first(), Cont_last() );