diff src/noffle.c @ 191:28488e0e3630 noffle

[svn] * src/group.h,src/group.c,src/noffle.c,src/server.c: Grp_setLastAccess is only ever called with last param as time(NULL), so remove it and call time() inside the implementation of Grp_setLastAccess. * src/client.c,src/group.h,src/group.c,src/noffle.c,src/post.c: Groups are automatically unsubscribed when the last access to the group is older than a particular threshold. However, for very low traffic groups, the last access may exceed the threshold simply because there has been no new article posted. In this case, rather than unsubscribe, update the group last access time. This means that groups are now only unsubscribed if the last access exceeds the threshold AND articles have arrived in the group since. Add Grp_setLastPostTime() to track the last time an article arrived in the group.
author bears
date Sat, 20 Oct 2001 14:23:46 +0100
parents f1bacee93ca6
children b9ef99708d1c
line wrap: on
line diff
--- a/src/noffle.c	Fri Oct 05 16:44:22 2001 +0100
+++ b/src/noffle.c	Sat Oct 20 14:23:46 2001 +0100
@@ -10,7 +10,7 @@
   received for some seconds (to allow multiple clients connect at the same
   time).
 
-  $Id: noffle.c 307 2001-09-12 20:33:44Z bears $
+  $Id: noffle.c 310 2001-10-20 13:23:46Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -272,12 +272,25 @@
                  && autoUnsubscribe
                  && difftime( now, Grp_lastAccess( 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 );
+		/* 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 );		    
+		}
             }
             Cont_write();
             Grp_setFirstLast( grp, Cont_first(), Cont_last() );
@@ -504,7 +517,7 @@
                 "thread" : "overview" );
     if ( ! Fetchlist_write() )
         fprintf( stderr, "Could not save fetchlist.\n" );
-    Grp_setLastAccess( name, time( NULL ) );
+    Grp_setLastAccess( name );
     return TRUE;
 }