Fossil SCM

Report on the email notification setup and status in the /stat page for administrators.

drh 2018-06-25 20:56 trunk
Commit 4ef590906d161d86df7ec1c29a22707802c0aa186631ca0d501a2dd9d5ff2b17
2 files changed +1 -1 +50
+1 -1
--- src/email.c
+++ src/email.c
@@ -1445,11 +1445,11 @@
14451445
Stmt q;
14461446
double rNow;
14471447
if( email_webpages_disabled() ) return;
14481448
login_check_credentials();
14491449
if( !g.perm.Admin ){
1450
- fossil_redirect_home();
1450
+ login_needed(0);
14511451
return;
14521452
}
14531453
email_submenu_common();
14541454
style_header("Subscriber List");
14551455
blob_init(&sql, 0, 0);
14561456
--- src/email.c
+++ src/email.c
@@ -1445,11 +1445,11 @@
1445 Stmt q;
1446 double rNow;
1447 if( email_webpages_disabled() ) return;
1448 login_check_credentials();
1449 if( !g.perm.Admin ){
1450 fossil_redirect_home();
1451 return;
1452 }
1453 email_submenu_common();
1454 style_header("Subscriber List");
1455 blob_init(&sql, 0, 0);
1456
--- src/email.c
+++ src/email.c
@@ -1445,11 +1445,11 @@
1445 Stmt q;
1446 double rNow;
1447 if( email_webpages_disabled() ) return;
1448 login_check_credentials();
1449 if( !g.perm.Admin ){
1450 login_needed(0);
1451 return;
1452 }
1453 email_submenu_common();
1454 style_header("Subscriber List");
1455 blob_init(&sql, 0, 0);
1456
+50
--- src/stat.c
+++ src/stat.c
@@ -198,10 +198,60 @@
198198
@ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
199199
@ %,d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
200200
@ %s(db_text(0, "PRAGMA repository.encoding")),
201201
@ %s(db_text(0, "PRAGMA repository.journal_mode")) mode
202202
@ </td></tr>
203
+ if( g.perm.Admin && email_enabled() ){
204
+ const char *zDest = db_get("email-send-method",0);
205
+ int nSub, nASub, nPend, nDPend;
206
+ const char *zDir, *zDb, *zCmd;
207
+ @ <tr><th>Outgoing&nbsp;Email:</th><td>
208
+ if( fossil_strcmp(zDest,"pipe")==0
209
+ && (zCmd = db_get("email-send-command",0))!=0
210
+ ){
211
+ @ Piped to command "%h(zCmd)"
212
+ }else
213
+ if( fossil_strcmp(zDest,"db")==0
214
+ && (zDb = db_get("email-send-db",0))!=0
215
+ ){
216
+ sqlite3 *db;
217
+ sqlite3_stmt *pStmt;
218
+ int rc;
219
+ @ Queued to database "%h(zDb)"
220
+ rc = sqlite3_open(zDb, &db);
221
+ if( rc==SQLITE_OK ){
222
+ rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0);
223
+ if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
224
+ @ (%,d(sqlite3_column_int(pStmt,0)) messages,
225
+ @ %,d(file_size(zDb,ExtFILE)) bytes)
226
+ }
227
+ sqlite3_finalize(pStmt);
228
+ }
229
+ sqlite3_close(db);
230
+ }else
231
+ if( fossil_strcmp(zDest,"dir")==0
232
+ && (zDir = db_get("email-send-dir",0))!=0
233
+ ){
234
+ @ Written to files in "%h(zDir)"
235
+ @ (%,d(file_directory_size(zDir,0,1)) messages)
236
+ }else{
237
+ @ Off
238
+ }
239
+ @ </td></tr>
240
+ nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
241
+ nDPend = db_int(0,"SELECT count(*) FROM pending_alert"
242
+ " WHERE NOT sentDigest");
243
+ @ <tr><th>Alerts:</th><td>
244
+ @ %,d(nPend) normal, %,d(nDPend) digest
245
+ @ </td></tr>
246
+ @ <tr><th>Subscribers:</th><td>
247
+ nSub = db_int(0, "SELECT count(*) FROM subscriber");
248
+ nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
249
+ " AND NOT sdonotcall AND length(ssub)>1");
250
+ @ %,d(nASub) active, %,d(nSub) total
251
+ @ </td></tr>
252
+ }
203253
204254
@ </table>
205255
style_footer();
206256
}
207257
208258
--- src/stat.c
+++ src/stat.c
@@ -198,10 +198,60 @@
198 @ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
199 @ %,d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
200 @ %s(db_text(0, "PRAGMA repository.encoding")),
201 @ %s(db_text(0, "PRAGMA repository.journal_mode")) mode
202 @ </td></tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
204 @ </table>
205 style_footer();
206 }
207
208
--- src/stat.c
+++ src/stat.c
@@ -198,10 +198,60 @@
198 @ %d(db_int(0, "PRAGMA repository.page_size")) bytes/page,
199 @ %,d(db_int(0, "PRAGMA repository.freelist_count")) free pages,
200 @ %s(db_text(0, "PRAGMA repository.encoding")),
201 @ %s(db_text(0, "PRAGMA repository.journal_mode")) mode
202 @ </td></tr>
203 if( g.perm.Admin && email_enabled() ){
204 const char *zDest = db_get("email-send-method",0);
205 int nSub, nASub, nPend, nDPend;
206 const char *zDir, *zDb, *zCmd;
207 @ <tr><th>Outgoing&nbsp;Email:</th><td>
208 if( fossil_strcmp(zDest,"pipe")==0
209 && (zCmd = db_get("email-send-command",0))!=0
210 ){
211 @ Piped to command "%h(zCmd)"
212 }else
213 if( fossil_strcmp(zDest,"db")==0
214 && (zDb = db_get("email-send-db",0))!=0
215 ){
216 sqlite3 *db;
217 sqlite3_stmt *pStmt;
218 int rc;
219 @ Queued to database "%h(zDb)"
220 rc = sqlite3_open(zDb, &db);
221 if( rc==SQLITE_OK ){
222 rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0);
223 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
224 @ (%,d(sqlite3_column_int(pStmt,0)) messages,
225 @ %,d(file_size(zDb,ExtFILE)) bytes)
226 }
227 sqlite3_finalize(pStmt);
228 }
229 sqlite3_close(db);
230 }else
231 if( fossil_strcmp(zDest,"dir")==0
232 && (zDir = db_get("email-send-dir",0))!=0
233 ){
234 @ Written to files in "%h(zDir)"
235 @ (%,d(file_directory_size(zDir,0,1)) messages)
236 }else{
237 @ Off
238 }
239 @ </td></tr>
240 nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
241 nDPend = db_int(0,"SELECT count(*) FROM pending_alert"
242 " WHERE NOT sentDigest");
243 @ <tr><th>Alerts:</th><td>
244 @ %,d(nPend) normal, %,d(nDPend) digest
245 @ </td></tr>
246 @ <tr><th>Subscribers:</th><td>
247 nSub = db_int(0, "SELECT count(*) FROM subscriber");
248 nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
249 " AND NOT sdonotcall AND length(ssub)>1");
250 @ %,d(nASub) active, %,d(nSub) total
251 @ </td></tr>
252 }
253
254 @ </table>
255 style_footer();
256 }
257
258

Keyboard Shortcuts

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