Fossil SCM
More infrastructure for expiring subscriptions for inactive accounts. But the functionality is not complete and does not actually do anything, yet.
Commit
7b8be208bc9b6370c1c4fecd1ef86bca309740a9d4d1e2b0fb0d27e5b8d1598c
Parent
d7e10ce4da9d9ec…
1 file changed
+62
+62
| --- src/alerts.c | ||
| +++ src/alerts.c | ||
| @@ -287,10 +287,23 @@ | ||
| 287 | 287 | @ This is short name used to identifies the repository in the |
| 288 | 288 | @ Subject: line of email alerts. Traditionally this name is |
| 289 | 289 | @ included in square brackets. Examples: "[fossil-src]", "[sqlite-src]". |
| 290 | 290 | @ (Property: "email-subname")</p> |
| 291 | 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> | |
| 292 | 305 | |
| 293 | 306 | multiple_choice_attribute("Email Send Method", "email-send-method", "esm", |
| 294 | 307 | "off", count(azSendMethods)/2, azSendMethods); |
| 295 | 308 | @ <p>How to send email. Requires auxiliary information from the fields |
| 296 | 309 | @ that follow. Hint: Use the <a href="%R/announce">/announce</a> page |
| @@ -1946,10 +1959,59 @@ | ||
| 1946 | 1959 | db_finalize(&q); |
| 1947 | 1960 | style_finish_page(); |
| 1948 | 1961 | db_commit_transaction(); |
| 1949 | 1962 | return; |
| 1950 | 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 | + | |
| 1951 | 2013 | |
| 1952 | 2014 | /* This is the message that gets sent to describe how to change |
| 1953 | 2015 | ** or modify a subscription |
| 1954 | 2016 | */ |
| 1955 | 2017 | static const char zUnsubMsg[] = |
| 1956 | 2018 |
| --- 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 |