Fossil SCM
Show the email notification status at the top of the /setup_notification page.
Commit
308f4065465fa79a9518b0e6703e3a9b3e815de124177cedfe1c986a09a82c63
Parent
8ac5bbbdb0107e6…
2 files changed
+10
+61
-48
+10
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -204,10 +204,20 @@ | ||
| 204 | 204 | db_begin_transaction(); |
| 205 | 205 | |
| 206 | 206 | email_submenu_common(); |
| 207 | 207 | style_submenu_element("Send Announcement","%R/announce"); |
| 208 | 208 | style_header("Email Notification Setup"); |
| 209 | + @ <h1>Status</h1> | |
| 210 | + @ <table class="label-value"> | |
| 211 | + if( email_enabled() ){ | |
| 212 | + stats_for_email(); | |
| 213 | + }else{ | |
| 214 | + @ <th>Disabled</th> | |
| 215 | + } | |
| 216 | + @ </table> | |
| 217 | + @ <hr> | |
| 218 | + @ <h1> Configuration </h1> | |
| 209 | 219 | @ <form action="%R/setup_notification" method="post"><div> |
| 210 | 220 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 211 | 221 | login_insert_csrf_secret(); |
| 212 | 222 | |
| 213 | 223 | entry_attribute("Canonical Server URL", 40, "email-url", |
| 214 | 224 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -204,10 +204,20 @@ | |
| 204 | db_begin_transaction(); |
| 205 | |
| 206 | email_submenu_common(); |
| 207 | style_submenu_element("Send Announcement","%R/announce"); |
| 208 | style_header("Email Notification Setup"); |
| 209 | @ <form action="%R/setup_notification" method="post"><div> |
| 210 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 211 | login_insert_csrf_secret(); |
| 212 | |
| 213 | entry_attribute("Canonical Server URL", 40, "email-url", |
| 214 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -204,10 +204,20 @@ | |
| 204 | db_begin_transaction(); |
| 205 | |
| 206 | email_submenu_common(); |
| 207 | style_submenu_element("Send Announcement","%R/announce"); |
| 208 | style_header("Email Notification Setup"); |
| 209 | @ <h1>Status</h1> |
| 210 | @ <table class="label-value"> |
| 211 | if( email_enabled() ){ |
| 212 | stats_for_email(); |
| 213 | }else{ |
| 214 | @ <th>Disabled</th> |
| 215 | } |
| 216 | @ </table> |
| 217 | @ <hr> |
| 218 | @ <h1> Configuration </h1> |
| 219 | @ <form action="%R/setup_notification" method="post"><div> |
| 220 | @ <input type="submit" name="submit" value="Apply Changes" /><hr> |
| 221 | login_insert_csrf_secret(); |
| 222 | |
| 223 | entry_attribute("Canonical Server URL", 40, "email-url", |
| 224 |
+61
-48
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -51,10 +51,70 @@ | ||
| 51 | 51 | sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0); |
| 52 | 52 | }else{ |
| 53 | 53 | sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | + | |
| 57 | +/* | |
| 58 | +** Generate stats for the email notification subsystem. | |
| 59 | +*/ | |
| 60 | +void stats_for_email(void){ | |
| 61 | + const char *zDest = db_get("email-send-method",0); | |
| 62 | + int nSub, nASub, nPend, nDPend; | |
| 63 | + const char *zDir, *zDb, *zCmd, *zRelay; | |
| 64 | + @ <tr><th>Outgoing Email:</th><td> | |
| 65 | + if( fossil_strcmp(zDest,"pipe")==0 | |
| 66 | + && (zCmd = db_get("email-send-command",0))!=0 | |
| 67 | + ){ | |
| 68 | + @ Piped to command "%h(zCmd)" | |
| 69 | + }else | |
| 70 | + if( fossil_strcmp(zDest,"db")==0 | |
| 71 | + && (zDb = db_get("email-send-db",0))!=0 | |
| 72 | + ){ | |
| 73 | + sqlite3 *db; | |
| 74 | + sqlite3_stmt *pStmt; | |
| 75 | + int rc; | |
| 76 | + @ Queued to database "%h(zDb)" | |
| 77 | + rc = sqlite3_open(zDb, &db); | |
| 78 | + if( rc==SQLITE_OK ){ | |
| 79 | + rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0); | |
| 80 | + if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ | |
| 81 | + @ (%,d(sqlite3_column_int(pStmt,0)) messages, | |
| 82 | + @ %,d(file_size(zDb,ExtFILE)) bytes) | |
| 83 | + } | |
| 84 | + sqlite3_finalize(pStmt); | |
| 85 | + } | |
| 86 | + sqlite3_close(db); | |
| 87 | + }else | |
| 88 | + if( fossil_strcmp(zDest,"dir")==0 | |
| 89 | + && (zDir = db_get("email-send-dir",0))!=0 | |
| 90 | + ){ | |
| 91 | + @ Written to files in "%h(zDir)" | |
| 92 | + @ (%,d(file_directory_size(zDir,0,1)) messages) | |
| 93 | + }else | |
| 94 | + if( fossil_strcmp(zDest,"relay")==0 | |
| 95 | + && (zRelay = db_get("email-send-relayhost",0))!=0 | |
| 96 | + ){ | |
| 97 | + @ Relay to %h(zRelay) using SMTP | |
| 98 | + } | |
| 99 | + else{ | |
| 100 | + @ Off | |
| 101 | + } | |
| 102 | + @ </td></tr> | |
| 103 | + nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep"); | |
| 104 | + nDPend = db_int(0,"SELECT count(*) FROM pending_alert" | |
| 105 | + " WHERE NOT sentDigest"); | |
| 106 | + @ <tr><th>Pending Alerts:</th><td> | |
| 107 | + @ %,d(nPend) normal, %,d(nDPend) digest | |
| 108 | + @ </td></tr> | |
| 109 | + @ <tr><th>Subscribers:</th><td> | |
| 110 | + nSub = db_int(0, "SELECT count(*) FROM subscriber"); | |
| 111 | + nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified" | |
| 112 | + " AND NOT sdonotcall AND length(ssub)>1"); | |
| 113 | + @ %,d(nASub) active, %,d(nSub) total | |
| 114 | + @ </td></tr> | |
| 115 | +} | |
| 56 | 116 | |
| 57 | 117 | /* |
| 58 | 118 | ** WEBPAGE: stat |
| 59 | 119 | ** |
| 60 | 120 | ** Show statistics and global information about the repository. |
| @@ -207,58 +267,11 @@ | ||
| 207 | 267 | @ <td><a href='%R/errorlog'>%h(g.zErrlog)</a> (%,lld(szFile) bytes) |
| 208 | 268 | } |
| 209 | 269 | @ </td></tr> |
| 210 | 270 | } |
| 211 | 271 | if( g.perm.Admin && email_enabled() ){ |
| 212 | - const char *zDest = db_get("email-send-method",0); | |
| 213 | - int nSub, nASub, nPend, nDPend; | |
| 214 | - const char *zDir, *zDb, *zCmd; | |
| 215 | - @ <tr><th>Outgoing Email:</th><td> | |
| 216 | - if( fossil_strcmp(zDest,"pipe")==0 | |
| 217 | - && (zCmd = db_get("email-send-command",0))!=0 | |
| 218 | - ){ | |
| 219 | - @ Piped to command "%h(zCmd)" | |
| 220 | - }else | |
| 221 | - if( fossil_strcmp(zDest,"db")==0 | |
| 222 | - && (zDb = db_get("email-send-db",0))!=0 | |
| 223 | - ){ | |
| 224 | - sqlite3 *db; | |
| 225 | - sqlite3_stmt *pStmt; | |
| 226 | - int rc; | |
| 227 | - @ Queued to database "%h(zDb)" | |
| 228 | - rc = sqlite3_open(zDb, &db); | |
| 229 | - if( rc==SQLITE_OK ){ | |
| 230 | - rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0); | |
| 231 | - if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ | |
| 232 | - @ (%,d(sqlite3_column_int(pStmt,0)) messages, | |
| 233 | - @ %,d(file_size(zDb,ExtFILE)) bytes) | |
| 234 | - } | |
| 235 | - sqlite3_finalize(pStmt); | |
| 236 | - } | |
| 237 | - sqlite3_close(db); | |
| 238 | - }else | |
| 239 | - if( fossil_strcmp(zDest,"dir")==0 | |
| 240 | - && (zDir = db_get("email-send-dir",0))!=0 | |
| 241 | - ){ | |
| 242 | - @ Written to files in "%h(zDir)" | |
| 243 | - @ (%,d(file_directory_size(zDir,0,1)) messages) | |
| 244 | - }else{ | |
| 245 | - @ Off | |
| 246 | - } | |
| 247 | - @ </td></tr> | |
| 248 | - nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep"); | |
| 249 | - nDPend = db_int(0,"SELECT count(*) FROM pending_alert" | |
| 250 | - " WHERE NOT sentDigest"); | |
| 251 | - @ <tr><th>Pending Alerts:</th><td> | |
| 252 | - @ %,d(nPend) normal, %,d(nDPend) digest | |
| 253 | - @ </td></tr> | |
| 254 | - @ <tr><th>Subscribers:</th><td> | |
| 255 | - nSub = db_int(0, "SELECT count(*) FROM subscriber"); | |
| 256 | - nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified" | |
| 257 | - " AND NOT sdonotcall AND length(ssub)>1"); | |
| 258 | - @ %,d(nASub) active, %,d(nSub) total | |
| 259 | - @ </td></tr> | |
| 272 | + stats_for_email(); | |
| 260 | 273 | } |
| 261 | 274 | |
| 262 | 275 | @ </table> |
| 263 | 276 | style_footer(); |
| 264 | 277 | } |
| 265 | 278 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -51,10 +51,70 @@ | |
| 51 | sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0); |
| 52 | }else{ |
| 53 | sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | ** WEBPAGE: stat |
| 59 | ** |
| 60 | ** Show statistics and global information about the repository. |
| @@ -207,58 +267,11 @@ | |
| 207 | @ <td><a href='%R/errorlog'>%h(g.zErrlog)</a> (%,lld(szFile) bytes) |
| 208 | } |
| 209 | @ </td></tr> |
| 210 | } |
| 211 | if( g.perm.Admin && email_enabled() ){ |
| 212 | const char *zDest = db_get("email-send-method",0); |
| 213 | int nSub, nASub, nPend, nDPend; |
| 214 | const char *zDir, *zDb, *zCmd; |
| 215 | @ <tr><th>Outgoing Email:</th><td> |
| 216 | if( fossil_strcmp(zDest,"pipe")==0 |
| 217 | && (zCmd = db_get("email-send-command",0))!=0 |
| 218 | ){ |
| 219 | @ Piped to command "%h(zCmd)" |
| 220 | }else |
| 221 | if( fossil_strcmp(zDest,"db")==0 |
| 222 | && (zDb = db_get("email-send-db",0))!=0 |
| 223 | ){ |
| 224 | sqlite3 *db; |
| 225 | sqlite3_stmt *pStmt; |
| 226 | int rc; |
| 227 | @ Queued to database "%h(zDb)" |
| 228 | rc = sqlite3_open(zDb, &db); |
| 229 | if( rc==SQLITE_OK ){ |
| 230 | rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0); |
| 231 | if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 232 | @ (%,d(sqlite3_column_int(pStmt,0)) messages, |
| 233 | @ %,d(file_size(zDb,ExtFILE)) bytes) |
| 234 | } |
| 235 | sqlite3_finalize(pStmt); |
| 236 | } |
| 237 | sqlite3_close(db); |
| 238 | }else |
| 239 | if( fossil_strcmp(zDest,"dir")==0 |
| 240 | && (zDir = db_get("email-send-dir",0))!=0 |
| 241 | ){ |
| 242 | @ Written to files in "%h(zDir)" |
| 243 | @ (%,d(file_directory_size(zDir,0,1)) messages) |
| 244 | }else{ |
| 245 | @ Off |
| 246 | } |
| 247 | @ </td></tr> |
| 248 | nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep"); |
| 249 | nDPend = db_int(0,"SELECT count(*) FROM pending_alert" |
| 250 | " WHERE NOT sentDigest"); |
| 251 | @ <tr><th>Pending Alerts:</th><td> |
| 252 | @ %,d(nPend) normal, %,d(nDPend) digest |
| 253 | @ </td></tr> |
| 254 | @ <tr><th>Subscribers:</th><td> |
| 255 | nSub = db_int(0, "SELECT count(*) FROM subscriber"); |
| 256 | nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified" |
| 257 | " AND NOT sdonotcall AND length(ssub)>1"); |
| 258 | @ %,d(nASub) active, %,d(nSub) total |
| 259 | @ </td></tr> |
| 260 | } |
| 261 | |
| 262 | @ </table> |
| 263 | style_footer(); |
| 264 | } |
| 265 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -51,10 +51,70 @@ | |
| 51 | sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0); |
| 52 | }else{ |
| 53 | sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | ** Generate stats for the email notification subsystem. |
| 59 | */ |
| 60 | void stats_for_email(void){ |
| 61 | const char *zDest = db_get("email-send-method",0); |
| 62 | int nSub, nASub, nPend, nDPend; |
| 63 | const char *zDir, *zDb, *zCmd, *zRelay; |
| 64 | @ <tr><th>Outgoing Email:</th><td> |
| 65 | if( fossil_strcmp(zDest,"pipe")==0 |
| 66 | && (zCmd = db_get("email-send-command",0))!=0 |
| 67 | ){ |
| 68 | @ Piped to command "%h(zCmd)" |
| 69 | }else |
| 70 | if( fossil_strcmp(zDest,"db")==0 |
| 71 | && (zDb = db_get("email-send-db",0))!=0 |
| 72 | ){ |
| 73 | sqlite3 *db; |
| 74 | sqlite3_stmt *pStmt; |
| 75 | int rc; |
| 76 | @ Queued to database "%h(zDb)" |
| 77 | rc = sqlite3_open(zDb, &db); |
| 78 | if( rc==SQLITE_OK ){ |
| 79 | rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0); |
| 80 | if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 81 | @ (%,d(sqlite3_column_int(pStmt,0)) messages, |
| 82 | @ %,d(file_size(zDb,ExtFILE)) bytes) |
| 83 | } |
| 84 | sqlite3_finalize(pStmt); |
| 85 | } |
| 86 | sqlite3_close(db); |
| 87 | }else |
| 88 | if( fossil_strcmp(zDest,"dir")==0 |
| 89 | && (zDir = db_get("email-send-dir",0))!=0 |
| 90 | ){ |
| 91 | @ Written to files in "%h(zDir)" |
| 92 | @ (%,d(file_directory_size(zDir,0,1)) messages) |
| 93 | }else |
| 94 | if( fossil_strcmp(zDest,"relay")==0 |
| 95 | && (zRelay = db_get("email-send-relayhost",0))!=0 |
| 96 | ){ |
| 97 | @ Relay to %h(zRelay) using SMTP |
| 98 | } |
| 99 | else{ |
| 100 | @ Off |
| 101 | } |
| 102 | @ </td></tr> |
| 103 | nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep"); |
| 104 | nDPend = db_int(0,"SELECT count(*) FROM pending_alert" |
| 105 | " WHERE NOT sentDigest"); |
| 106 | @ <tr><th>Pending Alerts:</th><td> |
| 107 | @ %,d(nPend) normal, %,d(nDPend) digest |
| 108 | @ </td></tr> |
| 109 | @ <tr><th>Subscribers:</th><td> |
| 110 | nSub = db_int(0, "SELECT count(*) FROM subscriber"); |
| 111 | nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified" |
| 112 | " AND NOT sdonotcall AND length(ssub)>1"); |
| 113 | @ %,d(nASub) active, %,d(nSub) total |
| 114 | @ </td></tr> |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | ** WEBPAGE: stat |
| 119 | ** |
| 120 | ** Show statistics and global information about the repository. |
| @@ -207,58 +267,11 @@ | |
| 267 | @ <td><a href='%R/errorlog'>%h(g.zErrlog)</a> (%,lld(szFile) bytes) |
| 268 | } |
| 269 | @ </td></tr> |
| 270 | } |
| 271 | if( g.perm.Admin && email_enabled() ){ |
| 272 | stats_for_email(); |
| 273 | } |
| 274 | |
| 275 | @ </table> |
| 276 | style_footer(); |
| 277 | } |
| 278 |