Fossil

Check-in [e0289252]
Login

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

Overview
Comment:Generate event report in chronological order for an alert text.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | email-alerts
Files: files | file ages | folders
SHA3-256: e02892522ecf7f3e79568a97f33ba5051f54f828caebc64c843e00a6367ec514
User & Date: drh 2018-06-22 15:57:46.315
Context
2018-06-22
17:36
A new way of computing alert text. ... (check-in: 6c06b1c8 user: drh tags: email-alerts)
15:57
Generate event report in chronological order for an alert text. ... (check-in: e0289252 user: drh tags: email-alerts)
15:34
Add logic to generate the text of email alert messages. ... (check-in: bb30d02e user: drh tags: email-alerts)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/email.c.
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@ -- The first character of the eventid determines the event type.
@ -- Remaining characters determine the specific event.  For example,
@ -- 'c4413' means check-in with rid=4413.
@ --
@ CREATE TABLE repository.pending_alert(
@   eventid TEXT PRIMARY KEY,         -- Object that changed
@   sentSep BOOLEAN DEFAULT false,    -- individual emails sent
@   sentDigest BOOLEAN DEFAULT false  -- digest emails sent
@ ) WITHOUT ROWID;
@ 
@ -- Record bounced emails.  If too many bounces are received within
@ -- some defined time range, then cancel the subscription.  Older
@ -- entries are periodically purged.
@ --
@ CREATE TABLE repository.email_bounce(







|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@ -- The first character of the eventid determines the event type.
@ -- Remaining characters determine the specific event.  For example,
@ -- 'c4413' means check-in with rid=4413.
@ --
@ CREATE TABLE repository.pending_alert(
@   eventid TEXT PRIMARY KEY,         -- Object that changed
@   sentSep BOOLEAN DEFAULT false,    -- individual emails sent
@   mtime DATETIME                    -- when added to queue
@ ) WITHOUT ROWID;
@ 
@ -- Record bounced emails.  If too many bounces are received within
@ -- some defined time range, then cancel the subscription.  Older
@ -- entries are periodically purged.
@ --
@ CREATE TABLE repository.email_bounce(
101
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
** table.
*/
void email_triggers_enable(void){
  if( !db_table_exists("repository","pending_alert") ) return;
  db_multi_exec(
    "CREATE TRIGGER IF NOT EXISTS repository.email_trigger1\n"
    "AFTER INSERT ON event BEGIN\n"
    "  INSERT INTO pending_alert(eventid)\n"
    "    SELECT printf('%%.1c%%d',new.type,new.objid) WHERE true\n"

    "    ON CONFLICT(eventId) DO NOTHING;\n"
    "END;"
  );
}

/*
** Disable triggers the event_pending triggers.







|
|
>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
** table.
*/
void email_triggers_enable(void){
  if( !db_table_exists("repository","pending_alert") ) return;
  db_multi_exec(
    "CREATE TRIGGER IF NOT EXISTS repository.email_trigger1\n"
    "AFTER INSERT ON event BEGIN\n"
    "  INSERT INTO pending_alert(eventid,mtime)\n"
    "    SELECT printf('%%.1c%%d',new.type,new.objid),"
    "           julianday('now') WHERE true\n"
    "    ON CONFLICT(eventId) DO NOTHING;\n"
    "END;"
  );
}

/*
** Disable triggers the event_pending triggers.
1339
1340
1341
1342
1343
1344
1345

1346



1347
1348
1349
1350
1351
1352
1353
  db_find_and_open_repository(0, 0);
  verify_all_options();
  email_schema();
  blob_init(&out, 0, 0);
  email_header(mAlert, &out);
  if( bActual ){
    Stmt q;

    db_prepare(&q, "SELECT eventid FROM pending_alert");



    while( db_step(&q)==SQLITE_ROW ){
      email_one_alert(db_column_text(&q,0), mAlert, &out);
    }
    db_finalize(&q);
  }else{
    int i;
    for(i=2; i<g.argc; i++){







>
|
>
>
>







1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
  db_find_and_open_repository(0, 0);
  verify_all_options();
  email_schema();
  blob_init(&out, 0, 0);
  email_header(mAlert, &out);
  if( bActual ){
    Stmt q;
    db_prepare(&q,
       "SELECT eventid FROM pending_alert, event"
       " WHERE event.objid=substr(pending_alert.eventid,2)+0"
       " ORDER BY event.mtime"
    );
    while( db_step(&q)==SQLITE_ROW ){
      email_one_alert(db_column_text(&q,0), mAlert, &out);
    }
    db_finalize(&q);
  }else{
    int i;
    for(i=2; i<g.argc; i++){