Comments (6)
Comments from JIRA:
NaNg:
attached.
Note that this will not send a reminder to users who have reset their account in the last > CLEANUP_ACCOUNT_NOTIFY days due to the use of lockuntil value, but i think it can be assumed that > if they used a reset or such things they will try to re-auth.
retropc:
I'm not sure overleading lockuntil is a good idea, the logic for that is already extremely obtuse/complicated.
NaNg:
Attached (reminderemail) another diff with a new value,
Note that this needs DB altering:
ALTER TABLE chanserv.users ADD COLUMN reminderemail INT;
UPDATE chanserv.users SET reminderemail = 0;
ALTER TABLE chanserv.users ALTER COLUMN reminderemail SET NOT NULL;
for your consideration.
from newserv.
Patches by NaNg:
notify.diff:
diff -r f8a208449bdf chanserv/batcher/templates.py
--- a/chanserv/batcher/templates.py Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/batcher/templates.py Sat Aug 23 13:31:35 2014 +0200
@@ -139,6 +139,13 @@
/AUTH %(user.username)s %(user.password)s
""", },
+ 7: { "subject": "%(config.bot)s account is about to expire", "body": """
+Your %(config.bot)s account is about to expire due to inactivity for %(config.cleanup)d days.
+
+Please consider reconnecting to the network and authenticating to your account to prevent it expiring.
+
+For more information please visit the %(config.bot)s help section at %(config.siteurl)s
+""", },
},
},
}
diff -r f8a208449bdf chanserv/chanserv.h
--- a/chanserv/chanserv.h Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/chanserv.h Sat Aug 23 13:31:35 2014 +0200
@@ -96,6 +96,7 @@
/* Cleanup options */
#define CLEANUP_ACCOUNT_INACTIVE 180
#define CLEANUP_ACCOUNT_UNUSED 3
+#define CLEANUP_ACCOUNT_NOTIFY 30
#define CLEANUP_CHANNEL_INACTIVE 40
#define CLEANUP_AUTHHISTORY 60
@@ -262,6 +263,7 @@
#define QMAIL_RESET 4 /* reset account */
#define QMAIL_NEWEMAIL 5 /* new email address */
#define QMAIL_ACTIVATEEMAIL 6 /* new style new account */
+#define QMAIL_NOTIFYACCOUNT 7 /* notify when an account is about to expire */
/* Channel flags */
diff -r f8a208449bdf chanserv/chanserv_cleanupdb.c
--- a/chanserv/chanserv_cleanupdb.c Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/chanserv_cleanupdb.c Sat Aug 23 13:31:35 2014 +0200
@@ -52,8 +52,8 @@
regchanuser *rcup, *nrcup;
authname *anp;
int i,j;
- time_t t, to_age, unused_age, maxchan_age, authhistory_age;
- int expired = 0, unauthed = 0, chansvaped = 0;
+ time_t t, to_age, unused_age, notify_age, maxchan_age, authhistory_age;
+ int expired = 0, unauthed = 0, notified = 0, chansvaped = 0;
chanindex *cip, *ncip;
regchan *rcp;
DBResult *pgres;
@@ -63,6 +63,7 @@
t = time(NULL);
to_age = t - (CLEANUP_ACCOUNT_INACTIVE * 3600 * 24);
unused_age = t - (CLEANUP_ACCOUNT_UNUSED * 3600 * 24);
+ notify_age = t - (CLEANUP_ACCOUNT_NOTIFY * 3600 * 24);
maxchan_age = t - (CLEANUP_CHANNEL_INACTIVE * 3600 * 24);
authhistory_age = t - (CLEANUP_AUTHHISTORY * 3600 * 24);
@@ -109,6 +110,13 @@
} else if(!vrup->lastauth && (vrup->created < unused_age)) {
unauthed++;
cs_log(NULL, "CLEANUPDB unused user %s %u", vrup->username, vrup->ID);
+ } else if((vrup->lastauth && (vrup->lastauth < notify_age)) && (!vrup->lockuntil || vrup->lockuntil < notify_age)) {
+ notified++;
+ csdb_createmail(vrup, QMAIL_NOTIFYACCOUNT);
+ vrup->lockuntil = t;
+ csdb_updateuser(vrup);
+ cs_log(NULL, "CLEANUPDB notify user %s %u", vrup->username, vrup->ID);
+ continue;
} else {
continue;
}
@@ -174,7 +182,7 @@
csdb_cleanuphistories(authhistory_age);
- cleanuplog("Stats: %d accounts inactive for %d days, %d accounts weren't used within %d days, %d channels were inactive for %d days.", expired, CLEANUP_ACCOUNT_INACTIVE, unauthed, CLEANUP_ACCOUNT_UNUSED, chansvaped, CLEANUP_CHANNEL_INACTIVE);
+ cleanuplog("Stats: %d accounts inactive for %d days, %d accounts weren't used within %d days, %d accounts were notified for expiry in %d days, %d channels were inactive for %d days.", expired, CLEANUP_ACCOUNT_INACTIVE, unauthed, CLEANUP_ACCOUNT_UNUSED, notified, CLEANUP_ACCOUNT_NOTIFY, chansvaped, CLEANUP_CHANNEL_INACTIVE);
out:
cleanupdb_active=0;
reminderemail.diff:
diff -r f8a208449bdf chanserv/authlib.c
--- a/chanserv/authlib.c Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/authlib.c Mon Aug 25 22:39:09 2014 +0200
@@ -199,6 +199,7 @@
rup->suspendexp=0;
rup->suspendtime=0;
rup->lockuntil=0;
+ rup->reminderemail=0;
strncpy(rup->password,password,PASSLEN); rup->password[PASSLEN]='\0';
rup->email=getsstring(email,EMAILLEN);
rup->lastemail=NULL;
diff -r f8a208449bdf chanserv/batcher/templates.py
--- a/chanserv/batcher/templates.py Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/batcher/templates.py Mon Aug 25 22:39:09 2014 +0200
@@ -139,6 +139,13 @@
/AUTH %(user.username)s %(user.password)s
""", },
+ 7: { "subject": "%(config.bot)s account is about to expire", "body": """
+Your %(config.bot)s account is about to expire due to inactivity for %(config.cleanup)d days.
+
+Please consider reconnecting to the network and authenticating to your account to prevent it expiring.
+
+For more information please visit the %(config.bot)s help section at %(config.siteurl)s
+""", },
},
},
}
diff -r f8a208449bdf chanserv/chanserv.h
--- a/chanserv/chanserv.h Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/chanserv.h Mon Aug 25 22:39:09 2014 +0200
@@ -96,6 +96,7 @@
/* Cleanup options */
#define CLEANUP_ACCOUNT_INACTIVE 180
#define CLEANUP_ACCOUNT_UNUSED 3
+#define CLEANUP_ACCOUNT_NOTIFY 7
#define CLEANUP_CHANNEL_INACTIVE 40
#define CLEANUP_AUTHHISTORY 60
@@ -262,6 +263,7 @@
#define QMAIL_RESET 4 /* reset account */
#define QMAIL_NEWEMAIL 5 /* new email address */
#define QMAIL_ACTIVATEEMAIL 6 /* new style new account */
+#define QMAIL_NOTIFYACCOUNT 7 /* notify when an account is about to expire */
/* Channel flags */
@@ -601,6 +603,7 @@
nick *fakeuser; /* If we had to "take" the nick, here's the pointer */
time_t lastpasschange;
+ time_t reminderemail;
struct reguser *nextbydomain;
struct reguser *nextbyname;
diff -r f8a208449bdf chanserv/chanserv_cleanupdb.c
--- a/chanserv/chanserv_cleanupdb.c Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/chanserv_cleanupdb.c Mon Aug 25 22:39:09 2014 +0200
@@ -52,8 +52,8 @@
regchanuser *rcup, *nrcup;
authname *anp;
int i,j;
- time_t t, to_age, unused_age, maxchan_age, authhistory_age;
- int expired = 0, unauthed = 0, chansvaped = 0;
+ time_t t, to_age, unused_age, notify_age, maxchan_age, authhistory_age;
+ int expired = 0, unauthed = 0, notified = 0, chansvaped = 0;
chanindex *cip, *ncip;
regchan *rcp;
DBResult *pgres;
@@ -63,6 +63,7 @@
t = time(NULL);
to_age = t - (CLEANUP_ACCOUNT_INACTIVE * 3600 * 24);
unused_age = t - (CLEANUP_ACCOUNT_UNUSED * 3600 * 24);
+ notify_age = t - (CLEANUP_ACCOUNT_NOTIFY * 3600 * 24);
maxchan_age = t - (CLEANUP_CHANNEL_INACTIVE * 3600 * 24);
authhistory_age = t - (CLEANUP_AUTHHISTORY * 3600 * 24);
@@ -109,6 +110,13 @@
} else if(!vrup->lastauth && (vrup->created < unused_age)) {
unauthed++;
cs_log(NULL, "CLEANUPDB unused user %s %u", vrup->username, vrup->ID);
+ } else if((vrup->lastauth && (vrup->lastauth < notify_age)) && (!vrup->reminderemail || vrup->reminderemail < notify_age)) {
+ notified++;
+ csdb_createmail(vrup, QMAIL_NOTIFYACCOUNT);
+ vrup->reminderemail = t;
+ csdb_updateuser(vrup);
+ cs_log(NULL, "CLEANUPDB notify user %s %u", vrup->username, vrup->ID);
+ continue;
} else {
continue;
}
@@ -174,7 +182,7 @@
csdb_cleanuphistories(authhistory_age);
- cleanuplog("Stats: %d accounts inactive for %d days, %d accounts weren't used within %d days, %d channels were inactive for %d days.", expired, CLEANUP_ACCOUNT_INACTIVE, unauthed, CLEANUP_ACCOUNT_UNUSED, chansvaped, CLEANUP_CHANNEL_INACTIVE);
+ cleanuplog("Stats: %d accounts inactive for %d days, %d accounts weren't used within %d days, %d accounts were notified for expiry in %d days, %d channels were inactive for %d days.", expired, CLEANUP_ACCOUNT_INACTIVE, unauthed, CLEANUP_ACCOUNT_UNUSED, notified, CLEANUP_ACCOUNT_NOTIFY, chansvaped, CLEANUP_CHANNEL_INACTIVE);
out:
cleanupdb_active=0;
diff -r f8a208449bdf chanserv/chanservdb_updates.c
--- a/chanserv/chanservdb_updates.c Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/chanservdb_updates.c Mon Aug 25 22:39:09 2014 +0200
@@ -244,11 +244,11 @@
dbquery("UPDATE chanserv.users SET lastauth=%lu, lastemailchng=%lu, flags=%u,"
"language=%u, suspendby=%u, suspendexp=%lu, suspendtime=%lu, lockuntil=%lu, password='%s', email='%s',"
- "lastuserhost='%s', suspendreason='%s', comment='%s', info='%s', lastemail='%s', lastpasschng=%lu "
+ "lastuserhost='%s', suspendreason='%s', comment='%s', info='%s', lastemail='%s', lastpasschng=%lu, reminderemail=%lu "
" WHERE ID=%u",
rup->lastauth, rup->lastemailchange, rup->flags, rup->languageid, rup->suspendby, rup->suspendexp,
rup->suspendtime, rup->lockuntil, escpassword, escemail, esclastuserhost, escreason, esccomment, escinfo, esclastemail,
- rup->lastpasschange,
+ rup->lastpasschange, rup->reminderemail,
rup->ID);
}
@@ -297,12 +297,12 @@
dbquery("INSERT INTO chanserv.users (ID, username, created, lastauth, lastemailchng, "
"flags, language, suspendby, suspendexp, suspendtime, lockuntil, password, email, lastuserhost, "
- "suspendreason, comment, info, lastemail, lastpasschng)"
- "VALUES (%u,'%s',%lu,%lu,%lu,%u,%u,%u,%lu,%lu,%lu,'%s','%s','%s','%s','%s','%s','%s',%lu)",
+ "suspendreason, comment, info, lastemail, lastpasschng, reminderemail)"
+ "VALUES (%u,'%s',%lu,%lu,%lu,%u,%u,%u,%lu,%lu,%lu,'%s','%s','%s','%s','%s','%s','%s',%lu,%lu)",
rup->ID, escusername, rup->created, rup->lastauth, rup->lastemailchange, rup->flags,
rup->languageid, rup->suspendby, rup->suspendexp, rup->suspendtime, rup->lockuntil,
escpassword, escemail, esclastuserhost, escreason, esccomment, escinfo, esclastemail,
- rup->lastpasschange);
+ rup->lastpasschange, rup->reminderemail);
}
diff -r f8a208449bdf chanserv/chanservuser.c
--- a/chanserv/chanservuser.c Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/chanservuser.c Mon Aug 25 22:39:09 2014 +0200
@@ -623,6 +623,7 @@
rup->lastauth=0;
rup->lastemailchange=0;
rup->lastpasschange=0;
+ rup->reminderemail=0;
rup->flags=QUFLAG_NOTICE;
rup->languageid=0;
rup->suspendby=0;
diff -r f8a208449bdf chanserv/database/chanservdb.c
--- a/chanserv/database/chanservdb.c Sat Jul 19 23:12:53 2014 +0200
+++ b/chanserv/database/chanservdb.c Mon Aug 25 22:39:09 2014 +0200
@@ -92,6 +92,7 @@
"comment VARCHAR(250),"
"info VARCHAR(100),"
"lastpasschng INT NOT NULL,"
+ "reminderemail INT NOT NULL,"
"PRIMARY KEY (ID))");
dbcreatequery("CREATE INDEX user_username_index ON chanserv.users (username)");
@@ -305,7 +306,7 @@
return;
}
- if (dbnumfields(pgres)!=19) {
+ if (dbnumfields(pgres)!=20) {
Error("chanserv",ERR_ERROR,"User DB format error");
return;
}
@@ -347,6 +348,7 @@
rup->comment=getsstring(dbgetvalue(pgres,16),250);
rup->info=getsstring(dbgetvalue(pgres,17),100);
rup->lastpasschange=strtoul(dbgetvalue(pgres,18),NULL,10);
+ rup->reminderemail=strtoul(dbgetvalue(pgres,19),NULL,10);
rup->knownon=NULL;
rup->checkshd=NULL;
rup->stealcount=0;
from newserv.
unless we can get around gmail marking our emails as spam: wontfix (because users will mark their expiring accounts they don't care about as spam)
from newserv.
If this is wontfix, any reason this issue is still open?
from newserv.
nope
from newserv.
(bear in mind I spent a good hour porting these issues from JIRA, so there's a few that might not be in a perfect state)
from newserv.
Related Issues (20)
- Add VOICEREG channel flag to chanserv
- Add a delayed auto-voice to chanserv
- REQUESTPASSWORD / SENDPASSWORD should send a change code rather than the password HOT 1
- RESET modified to copy old hashed password into current password
- Remove password from accounthistory, databases, logs
- CHALLENGEAUTH replacement that doesn't rely on plaintext password
- allow challengeauth to work for legacy accounts, but not new ones
- Example code of challengeauth replacement
- Core chanserv password hashing changes
- Authgate changes for password hashing (CHECKHASHPASS)
- Add scrypt support to newserv
- TRUSTLOGGREP showing ID and trust limit the wrong way round
- pqsql/chanserv: Does not survive PostgreSQL server restart HOT 1
- nterfacer protocol lacks forward secrecy HOT 1
- explain please about sql for newserv
- this possible run newserv without Q send email?
- Help please HOT 1
- Help please HOT 1
- lua dbapi should support parameterised queries
- lua dbapi should have script specific connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from newserv.