Fossil SCM

More infrastructure for expiring subscriptions for inactive accounts. But the functionality is not complete and does not actually do anything, yet.

drh 2021-05-28 21:12 trunk
Commit 7b8be208bc9b6370c1c4fecd1ef86bca309740a9d4d1e2b0fb0d27e5b8d1598c
1 file changed +62
+62
--- src/alerts.c
+++ src/alerts.c
@@ -287,10 +287,23 @@
287287
@ This is short name used to identifies the repository in the
288288
@ Subject: line of email alerts. Traditionally this name is
289289
@ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]".
290290
@ (Property: "email-subname")</p>
291291
@ <hr>
292
+
293
+ entry_attribute("Subscription Renewal Interval In Days", 8,
294
+ "email-renew-interval", "eri", "", 0);
295
+ @ <p>
296
+ @ If this value is a positive integer N, then email notification
297
+ @ subscriptions will be suspended N days after the last known
298
+ @ interaction with the user. This prevents sending notifications
299
+ @ to abandoned accounts. If a subscription gets close to expiring
300
+ @ a separate email goes out with the daily digest that prompts the
301
+ @ subscriber to click on a link to the "/renew" webpage in order to
302
+ @ extend their subscription.
303
+ @ (Property: "email-renew-interval")</p>
304
+ @ <hr>
292305
293306
multiple_choice_attribute("Email Send Method", "email-send-method", "esm",
294307
"off", count(azSendMethods)/2, azSendMethods);
295308
@ <p>How to send email. Requires auxiliary information from the fields
296309
@ that follow. Hint: Use the <a href="%R/announce">/announce</a> page
@@ -1946,10 +1959,59 @@
19461959
db_finalize(&q);
19471960
style_finish_page();
19481961
db_commit_transaction();
19491962
return;
19501963
}
1964
+
1965
+/*
1966
+** WEBPAGE: renew
1967
+**
1968
+** Users visit this page to update the lastContact date on their
1969
+** subscription. This prevents their subscriptions from expiring.
1970
+**
1971
+** A valid subscriber code is supplied in the name= query parameter.
1972
+*/
1973
+void renewal_page(void){
1974
+ const char *zName = P("name");
1975
+ int iInterval = db_get_int("email-renew-interval", 0);
1976
+ Stmt s;
1977
+ int rc;
1978
+
1979
+ style_header("Subscription Renewal");
1980
+ if( zName==0 || strlen(zName)<4 ){
1981
+ @ <p>No subscription specified</p>
1982
+ style_finish_page();
1983
+ return;
1984
+ }
1985
+
1986
+ if( !db_table_has_column("repository","subscriber","lastContact")
1987
+ || iInterval<1
1988
+ ){
1989
+ @ <p>This repository does not expire email notification subscriptions.
1990
+ @ No renewals are necessary.</p>
1991
+ style_finish_page();
1992
+ return;
1993
+ }
1994
+
1995
+ db_prepare(&s,
1996
+ "UPDATE subscriber"
1997
+ " SET lastContact=now()/86400"
1998
+ " WHERE subscriberCode=hextoblob(%Q)"
1999
+ " RETURNING semail, date('now','+%d days');",
2000
+ zName, iInterval+1
2001
+ );
2002
+ rc = db_step(&s);
2003
+ if( rc==SQLITE_ROW ){
2004
+ @ <p>The email notification subscription for %h(db_column_text(&s,0))
2005
+ @ has been extended until %h(db_column_text(&s,1)) UTC.
2006
+ }else{
2007
+ @ <p>No such subscriber-id: %h(zName)</p>
2008
+ }
2009
+ db_finalize(&s);
2010
+ style_finish_page();
2011
+}
2012
+
19512013
19522014
/* This is the message that gets sent to describe how to change
19532015
** or modify a subscription
19542016
*/
19552017
static const char zUnsubMsg[] =
19562018
--- src/alerts.c
+++ src/alerts.c
@@ -287,10 +287,23 @@
287 @ This is short name used to identifies the repository in the
288 @ Subject: line of email alerts. Traditionally this name is
289 @ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]".
290 @ (Property: "email-subname")</p>
291 @ <hr>
 
 
 
 
 
 
 
 
 
 
 
 
 
292
293 multiple_choice_attribute("Email Send Method", "email-send-method", "esm",
294 "off", count(azSendMethods)/2, azSendMethods);
295 @ <p>How to send email. Requires auxiliary information from the fields
296 @ that follow. Hint: Use the <a href="%R/announce">/announce</a> page
@@ -1946,10 +1959,59 @@
1946 db_finalize(&q);
1947 style_finish_page();
1948 db_commit_transaction();
1949 return;
1950 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1951
1952 /* This is the message that gets sent to describe how to change
1953 ** or modify a subscription
1954 */
1955 static const char zUnsubMsg[] =
1956
--- src/alerts.c
+++ src/alerts.c
@@ -287,10 +287,23 @@
287 @ This is short name used to identifies the repository in the
288 @ Subject: line of email alerts. Traditionally this name is
289 @ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]".
290 @ (Property: "email-subname")</p>
291 @ <hr>
292
293 entry_attribute("Subscription Renewal Interval In Days", 8,
294 "email-renew-interval", "eri", "", 0);
295 @ <p>
296 @ If this value is a positive integer N, then email notification
297 @ subscriptions will be suspended N days after the last known
298 @ interaction with the user. This prevents sending notifications
299 @ to abandoned accounts. If a subscription gets close to expiring
300 @ a separate email goes out with the daily digest that prompts the
301 @ subscriber to click on a link to the "/renew" webpage in order to
302 @ extend their subscription.
303 @ (Property: "email-renew-interval")</p>
304 @ <hr>
305
306 multiple_choice_attribute("Email Send Method", "email-send-method", "esm",
307 "off", count(azSendMethods)/2, azSendMethods);
308 @ <p>How to send email. Requires auxiliary information from the fields
309 @ that follow. Hint: Use the <a href="%R/announce">/announce</a> page
@@ -1946,10 +1959,59 @@
1959 db_finalize(&q);
1960 style_finish_page();
1961 db_commit_transaction();
1962 return;
1963 }
1964
1965 /*
1966 ** WEBPAGE: renew
1967 **
1968 ** Users visit this page to update the lastContact date on their
1969 ** subscription. This prevents their subscriptions from expiring.
1970 **
1971 ** A valid subscriber code is supplied in the name= query parameter.
1972 */
1973 void renewal_page(void){
1974 const char *zName = P("name");
1975 int iInterval = db_get_int("email-renew-interval", 0);
1976 Stmt s;
1977 int rc;
1978
1979 style_header("Subscription Renewal");
1980 if( zName==0 || strlen(zName)<4 ){
1981 @ <p>No subscription specified</p>
1982 style_finish_page();
1983 return;
1984 }
1985
1986 if( !db_table_has_column("repository","subscriber","lastContact")
1987 || iInterval<1
1988 ){
1989 @ <p>This repository does not expire email notification subscriptions.
1990 @ No renewals are necessary.</p>
1991 style_finish_page();
1992 return;
1993 }
1994
1995 db_prepare(&s,
1996 "UPDATE subscriber"
1997 " SET lastContact=now()/86400"
1998 " WHERE subscriberCode=hextoblob(%Q)"
1999 " RETURNING semail, date('now','+%d days');",
2000 zName, iInterval+1
2001 );
2002 rc = db_step(&s);
2003 if( rc==SQLITE_ROW ){
2004 @ <p>The email notification subscription for %h(db_column_text(&s,0))
2005 @ has been extended until %h(db_column_text(&s,1)) UTC.
2006 }else{
2007 @ <p>No such subscriber-id: %h(zName)</p>
2008 }
2009 db_finalize(&s);
2010 style_finish_page();
2011 }
2012
2013
2014 /* This is the message that gets sent to describe how to change
2015 ** or modify a subscription
2016 */
2017 static const char zUnsubMsg[] =
2018

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button