Mercurial > noffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
191:28488e0e3630 | 192:b9ef99708d1c |
---|---|
8 not as server. If noffle runs as server, locking is performed while | 8 not as server. If noffle runs as server, locking is performed while |
9 executing NNTP commands, but temporarily released if no new command is | 9 executing NNTP commands, but temporarily released if no new command is |
10 received for some seconds (to allow multiple clients connect at the same | 10 received for some seconds (to allow multiple clients connect at the same |
11 time). | 11 time). |
12 | 12 |
13 $Id: noffle.c 310 2001-10-20 13:23:46Z bears $ | 13 $Id: noffle.c 311 2001-10-21 11:00:12Z bears $ |
14 */ | 14 */ |
15 | 15 |
16 #if HAVE_CONFIG_H | 16 #if HAVE_CONFIG_H |
17 #include <config.h> | 17 #include <config.h> |
18 #endif | 18 #endif |
235 int i; | 235 int i; |
236 int cntDel, cntLeft; | 236 int cntDel, cntLeft; |
237 Str grp; | 237 Str grp; |
238 Bool autoUnsubscribe; | 238 Bool autoUnsubscribe; |
239 int autoUnsubscribeDays; | 239 int autoUnsubscribeDays; |
240 time_t now = time( NULL ), maxAge = 0; | 240 time_t maxAge = 0; |
241 const char *msgId; | 241 const char *msgId; |
242 | 242 |
243 autoUnsubscribe = Cfg_autoUnsubscribe(); | 243 autoUnsubscribe = Cfg_autoUnsubscribe(); |
244 autoUnsubscribeDays = Cfg_autoUnsubscribeDays(); | 244 autoUnsubscribeDays = Cfg_autoUnsubscribeDays(); |
245 maxAge = Cfg_autoUnsubscribeDays() * 24 * 3600; | 245 maxAge = Cfg_autoUnsubscribeDays() * 24 * 3600; |
265 ++cntDel; | 265 ++cntDel; |
266 } | 266 } |
267 else | 267 else |
268 ++cntLeft; | 268 ++cntLeft; |
269 } | 269 } |
270 | |
271 /* | |
272 * Auto unsubscribe where applicable if last article arrival | |
273 * time is maxAge newer than the last access time. This ensures | |
274 * the low traffic groups don't get expired simply because | |
275 * there's been nothing to read. | |
276 */ | |
270 if ( ! Grp_local( grp ) | 277 if ( ! Grp_local( grp ) |
271 && Fetchlist_contains( grp ) | 278 && Fetchlist_contains( grp ) |
272 && autoUnsubscribe | 279 && autoUnsubscribe |
273 && difftime( now, Grp_lastAccess( grp ) ) > maxAge ) | 280 && difftime( Grp_lastPostTime(grp), |
281 Grp_lastAccess( grp ) ) > maxAge ) | |
274 { | 282 { |
275 /* If there have been recent posts, unsubscribe. */ | 283 Log_ntc( "Auto-unsubscribing from %s after %d " |
276 if ( difftime( now, Grp_lastPostTime( grp ) ) <= maxAge ) | 284 "days without access", |
277 { | 285 grp, autoUnsubscribeDays ); |
278 Log_ntc( "Auto-unsubscribing from %s after %d " | 286 Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays ); |
279 "days without access", | 287 Fetchlist_remove( grp ); |
280 grp, autoUnsubscribeDays ); | 288 Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED ); |
281 Pseudo_autoUnsubscribed( grp, autoUnsubscribeDays ); | |
282 Fetchlist_remove( grp ); | |
283 Grp_setRmtNext( grp, GRP_RMT_NEXT_NOT_SUBSCRIBED ); | |
284 } | |
285 else | |
286 { | |
287 /* | |
288 * Otherwise if no recent posts touch the access. | |
289 * This way we don't unsubscribe to low volume groups | |
290 * unread only because there are no recent posts. | |
291 */ | |
292 Grp_setLastAccess( grp ); | |
293 } | |
294 } | 289 } |
295 Cont_write(); | 290 Cont_write(); |
296 Grp_setFirstLast( grp, Cont_first(), Cont_last() ); | 291 Grp_setFirstLast( grp, Cont_first(), Cont_last() ); |
297 Log_inf( "%ld overviews deleted from group %s, %ld left (%ld-%ld)", | 292 Log_inf( "%ld overviews deleted from group %s, %ld left (%ld-%ld)", |
298 cntDel, grp, cntLeft, Grp_first( grp ), Grp_last( grp ) ); | 293 cntDel, grp, cntLeft, Grp_first( grp ), Grp_last( grp ) ); |