Fossil

Check-in [308f4065]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Show the email notification status at the top of the /setup_notification page.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | webmail
Files: files | file ages | folders
SHA3-256:308f4065465fa79a9518b0e6703e3a9b3e815de124177cedfe1c986a09a82c63
User & Date: drh 2018-07-17 15:07:32
Context
2018-07-17
15:10
Fix a mimetype typo that prevents email notification from running. Closed-Leaf check-in: e2fd46dd user: drh tags: webmail
15:07
Show the email notification status at the top of the /setup_notification page. check-in: 308f4065 user: drh tags: webmail
14:47
Add the test-emailblob page. check-in: 8ac5bbbd user: drh tags: webmail
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/email.c.

202
203
204
205
206
207
208










209
210
211
212
213
214
215
    return;
  }
  db_begin_transaction();

  email_submenu_common();
  style_submenu_element("Send Announcement","%R/announce");
  style_header("Email Notification Setup");










  @ <form action="%R/setup_notification" method="post"><div>
  @ <input type="submit"  name="submit" value="Apply Changes" /><hr>
  login_insert_csrf_secret();

  entry_attribute("Canonical Server URL", 40, "email-url",
                   "eurl", "", 0);
  @ <p><b>Required.</b>







>
>
>
>
>
>
>
>
>
>







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    return;
  }
  db_begin_transaction();

  email_submenu_common();
  style_submenu_element("Send Announcement","%R/announce");
  style_header("Email Notification Setup");
  @ <h1>Status</h1>
  @ <table class="label-value">
  if( email_enabled() ){
    stats_for_email();
  }else{
    @ <th>Disabled</th>
  }
  @ </table>
  @ <hr>
  @ <h1> Configuration </h1>
  @ <form action="%R/setup_notification" method="post"><div>
  @ <input type="submit"  name="submit" value="Apply Changes" /><hr>
  login_insert_csrf_secret();

  entry_attribute("Canonical Server URL", 40, "email-url",
                   "eurl", "", 0);
  @ <p><b>Required.</b>

Changes to src/stat.c.

49
50
51
52
53
54
55




























































56
57
58
59
60
61
62
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
    sqlite3_snprintf(nOut, zOut, "%.1fKB", (double)v/1000.0);
  }else if( v<1000000000 ){
    sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0);
  }else{
    sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0);
  }
}





























































/*
** WEBPAGE: stat
**
** Show statistics and global information about the repository.
*/
void stat_page(void){
................................................................................
    if( szFile>=0 ){
      @ <tr><th>Error Log:</th>
      @ <td><a href='%R/errorlog'>%h(g.zErrlog)</a> (%,lld(szFile) bytes)
    }
    @ </td></tr>
  }
  if( g.perm.Admin && email_enabled() ){
    const char *zDest = db_get("email-send-method",0);
    int nSub, nASub, nPend, nDPend;
    const char *zDir, *zDb, *zCmd;
    @ <tr><th>Outgoing&nbsp;Email:</th><td>
    if( fossil_strcmp(zDest,"pipe")==0
     && (zCmd = db_get("email-send-command",0))!=0
    ){
      @ Piped to command "%h(zCmd)"
    }else
    if( fossil_strcmp(zDest,"db")==0
     && (zDb = db_get("email-send-db",0))!=0
    ){
      sqlite3 *db;
      sqlite3_stmt *pStmt;
      int rc;
      @ Queued to database "%h(zDb)"
      rc = sqlite3_open(zDb, &db);
      if( rc==SQLITE_OK ){
        rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0);
        if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
          @ (%,d(sqlite3_column_int(pStmt,0)) messages,
          @ %,d(file_size(zDb,ExtFILE)) bytes)
        }
        sqlite3_finalize(pStmt);
      }
      sqlite3_close(db);
    }else
    if( fossil_strcmp(zDest,"dir")==0
     && (zDir = db_get("email-send-dir",0))!=0
    ){
      @ Written to files in "%h(zDir)"
      @ (%,d(file_directory_size(zDir,0,1)) messages)
    }else{
      @ Off
    }
    @ </td></tr>
    nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
    nDPend = db_int(0,"SELECT count(*) FROM pending_alert"
                      " WHERE NOT sentDigest");
    @ <tr><th>Pending&nbsp;Alerts:</th><td>
    @ %,d(nPend) normal, %,d(nDPend) digest
    @ </td></tr>
    @ <tr><th>Subscribers:</th><td>
    nSub = db_int(0, "SELECT count(*) FROM subscriber");
    nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
                     " AND NOT sdonotcall AND length(ssub)>1");
    @ %,d(nASub) active, %,d(nSub) total
    @ </td></tr>
  }

  @ </table>
  style_footer();
}

/*







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
265
266
267
268
269
270
271
272















































273
274
275
276
277
278
279
    sqlite3_snprintf(nOut, zOut, "%.1fKB", (double)v/1000.0);
  }else if( v<1000000000 ){
    sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0);
  }else{
    sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0);
  }
}

/*
** Generate stats for the email notification subsystem.
*/
void stats_for_email(void){
  const char *zDest = db_get("email-send-method",0);
  int nSub, nASub, nPend, nDPend;
  const char *zDir, *zDb, *zCmd, *zRelay;
  @ <tr><th>Outgoing&nbsp;Email:</th><td>
  if( fossil_strcmp(zDest,"pipe")==0
   && (zCmd = db_get("email-send-command",0))!=0
  ){
    @ Piped to command "%h(zCmd)"
  }else
  if( fossil_strcmp(zDest,"db")==0
   && (zDb = db_get("email-send-db",0))!=0
  ){
    sqlite3 *db;
    sqlite3_stmt *pStmt;
    int rc;
    @ Queued to database "%h(zDb)"
    rc = sqlite3_open(zDb, &db);
    if( rc==SQLITE_OK ){
      rc = sqlite3_prepare_v2(db, "SELECT count(*) FROM email",-1,&pStmt,0);
      if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
        @ (%,d(sqlite3_column_int(pStmt,0)) messages,
        @ %,d(file_size(zDb,ExtFILE)) bytes)
      }
      sqlite3_finalize(pStmt);
    }
    sqlite3_close(db);
  }else
  if( fossil_strcmp(zDest,"dir")==0
   && (zDir = db_get("email-send-dir",0))!=0
  ){
    @ Written to files in "%h(zDir)"
    @ (%,d(file_directory_size(zDir,0,1)) messages)
  }else
  if( fossil_strcmp(zDest,"relay")==0
   && (zRelay = db_get("email-send-relayhost",0))!=0
  ){
    @ Relay to %h(zRelay) using SMTP
  }
  else{
    @ Off
  }
  @ </td></tr>
  nPend = db_int(0,"SELECT count(*) FROM pending_alert WHERE NOT sentSep");
  nDPend = db_int(0,"SELECT count(*) FROM pending_alert"
                    " WHERE NOT sentDigest");
  @ <tr><th>Pending&nbsp;Alerts:</th><td>
  @ %,d(nPend) normal, %,d(nDPend) digest
  @ </td></tr>
  @ <tr><th>Subscribers:</th><td>
  nSub = db_int(0, "SELECT count(*) FROM subscriber");
  nASub = db_int(0, "SELECT count(*) FROM subscriber WHERE sverified"
                   " AND NOT sdonotcall AND length(ssub)>1");
  @ %,d(nASub) active, %,d(nSub) total
  @ </td></tr>
}

/*
** WEBPAGE: stat
**
** Show statistics and global information about the repository.
*/
void stat_page(void){
................................................................................
    if( szFile>=0 ){
      @ <tr><th>Error Log:</th>
      @ <td><a href='%R/errorlog'>%h(g.zErrlog)</a> (%,lld(szFile) bytes)
    }
    @ </td></tr>
  }
  if( g.perm.Admin && email_enabled() ){
    stats_for_email();















































  }

  @ </table>
  style_footer();
}

/*