Fossil SCM

In the webmail interface, provide the option to show the SMTP transcript when that transcript is available.

drh 2018-07-17 16:24 trunk
Commit bb8b60378deb428c4c10496755c7ee2b9fef21d08e49bd48eff0089397452eb0
3 files changed +5 -5 +1 +22 -1
+5 -5
--- src/smtp.c
+++ src/smtp.c
@@ -667,11 +667,11 @@
667667
@
668668
@ -- Outgoing email queue
669669
@ CREATE TABLE IF NOT EXISTS repository.emailoutq(
670670
@ edomain TEXT, -- Destination domain. (ex: "fossil-scm.org")
671671
@ efrom TEXT, -- Sender email address
672
-@ eto TEXT, -- Receipient email address
672
+@ eto TEXT, -- Recipient email address
673673
@ emsgid INT, -- Message body in the emailblob table
674674
@ ectime INT, -- Time enqueued. Seconds since 1970
675675
@ emtime INT, -- Time of last send attempt. Sec since 1970
676676
@ ensend INT, -- Number of send attempts
677677
@ ets INT -- Transcript of last failed attempt
@@ -1068,17 +1068,16 @@
10681068
db_begin_write();
10691069
if( p->idTranscript==0 ) smtp_server_schema(0);
10701070
p->nRef = 0;
10711071
db_prepare(&s,
10721072
"INSERT INTO emailblob(ets,etime,etxt,enref)"
1073
- " VALUES(:ets,now(),compress(:etxt),:enref)"
1073
+ " VALUES(:ets,now(),compress(:etxt),0)"
10741074
);
10751075
p->nEts++;
10761076
if( !bFinish && p->idTranscript==0 ){
10771077
db_bind_null(&s, ":ets");
10781078
db_bind_null(&s, ":etxt");
1079
- db_bind_int(&s, ":enref", 0);
10801079
db_step(&s);
10811080
db_reset(&s);
10821081
p->idTranscript = db_last_insert_rowid();
10831082
}else if( bFinish ){
10841083
if( p->idTranscript ){
@@ -1087,19 +1086,20 @@
10871086
" WHERE emailid=%lld",
10881087
blob_str(&p->transcript), p->nEts, p->idTranscript);
10891088
}else{
10901089
db_bind_null(&s, ":ets");
10911090
db_bind_str(&s, ":etxt", &p->transcript);
1092
- db_bind_int(&s, ":enref", p->nEts);
10931091
db_step(&s);
10941092
db_reset(&s);
10951093
p->idTranscript = db_last_insert_rowid();
1094
+ db_multi_exec(
1095
+ "UPDATE emailblob SET enref=%d WHERE emailid=%lld",
1096
+ p->nEts, p->idTranscript);
10961097
}
10971098
}
10981099
db_bind_int64(&s, ":ets", p->idTranscript);
10991100
db_bind_str(&s, ":etxt", &p->msg);
1100
- db_bind_int(&s, ":enref", 0);
11011101
db_step(&s);
11021102
db_finalize(&s);
11031103
p->idMsg = db_last_insert_rowid();
11041104
11051105
/* make entries in emailbox and emailoutq */
11061106
--- src/smtp.c
+++ src/smtp.c
@@ -667,11 +667,11 @@
667 @
668 @ -- Outgoing email queue
669 @ CREATE TABLE IF NOT EXISTS repository.emailoutq(
670 @ edomain TEXT, -- Destination domain. (ex: "fossil-scm.org")
671 @ efrom TEXT, -- Sender email address
672 @ eto TEXT, -- Receipient email address
673 @ emsgid INT, -- Message body in the emailblob table
674 @ ectime INT, -- Time enqueued. Seconds since 1970
675 @ emtime INT, -- Time of last send attempt. Sec since 1970
676 @ ensend INT, -- Number of send attempts
677 @ ets INT -- Transcript of last failed attempt
@@ -1068,17 +1068,16 @@
1068 db_begin_write();
1069 if( p->idTranscript==0 ) smtp_server_schema(0);
1070 p->nRef = 0;
1071 db_prepare(&s,
1072 "INSERT INTO emailblob(ets,etime,etxt,enref)"
1073 " VALUES(:ets,now(),compress(:etxt),:enref)"
1074 );
1075 p->nEts++;
1076 if( !bFinish && p->idTranscript==0 ){
1077 db_bind_null(&s, ":ets");
1078 db_bind_null(&s, ":etxt");
1079 db_bind_int(&s, ":enref", 0);
1080 db_step(&s);
1081 db_reset(&s);
1082 p->idTranscript = db_last_insert_rowid();
1083 }else if( bFinish ){
1084 if( p->idTranscript ){
@@ -1087,19 +1086,20 @@
1087 " WHERE emailid=%lld",
1088 blob_str(&p->transcript), p->nEts, p->idTranscript);
1089 }else{
1090 db_bind_null(&s, ":ets");
1091 db_bind_str(&s, ":etxt", &p->transcript);
1092 db_bind_int(&s, ":enref", p->nEts);
1093 db_step(&s);
1094 db_reset(&s);
1095 p->idTranscript = db_last_insert_rowid();
 
 
 
1096 }
1097 }
1098 db_bind_int64(&s, ":ets", p->idTranscript);
1099 db_bind_str(&s, ":etxt", &p->msg);
1100 db_bind_int(&s, ":enref", 0);
1101 db_step(&s);
1102 db_finalize(&s);
1103 p->idMsg = db_last_insert_rowid();
1104
1105 /* make entries in emailbox and emailoutq */
1106
--- src/smtp.c
+++ src/smtp.c
@@ -667,11 +667,11 @@
667 @
668 @ -- Outgoing email queue
669 @ CREATE TABLE IF NOT EXISTS repository.emailoutq(
670 @ edomain TEXT, -- Destination domain. (ex: "fossil-scm.org")
671 @ efrom TEXT, -- Sender email address
672 @ eto TEXT, -- Recipient email address
673 @ emsgid INT, -- Message body in the emailblob table
674 @ ectime INT, -- Time enqueued. Seconds since 1970
675 @ emtime INT, -- Time of last send attempt. Sec since 1970
676 @ ensend INT, -- Number of send attempts
677 @ ets INT -- Transcript of last failed attempt
@@ -1068,17 +1068,16 @@
1068 db_begin_write();
1069 if( p->idTranscript==0 ) smtp_server_schema(0);
1070 p->nRef = 0;
1071 db_prepare(&s,
1072 "INSERT INTO emailblob(ets,etime,etxt,enref)"
1073 " VALUES(:ets,now(),compress(:etxt),0)"
1074 );
1075 p->nEts++;
1076 if( !bFinish && p->idTranscript==0 ){
1077 db_bind_null(&s, ":ets");
1078 db_bind_null(&s, ":etxt");
 
1079 db_step(&s);
1080 db_reset(&s);
1081 p->idTranscript = db_last_insert_rowid();
1082 }else if( bFinish ){
1083 if( p->idTranscript ){
@@ -1087,19 +1086,20 @@
1086 " WHERE emailid=%lld",
1087 blob_str(&p->transcript), p->nEts, p->idTranscript);
1088 }else{
1089 db_bind_null(&s, ":ets");
1090 db_bind_str(&s, ":etxt", &p->transcript);
 
1091 db_step(&s);
1092 db_reset(&s);
1093 p->idTranscript = db_last_insert_rowid();
1094 db_multi_exec(
1095 "UPDATE emailblob SET enref=%d WHERE emailid=%lld",
1096 p->nEts, p->idTranscript);
1097 }
1098 }
1099 db_bind_int64(&s, ":ets", p->idTranscript);
1100 db_bind_str(&s, ":etxt", &p->msg);
 
1101 db_step(&s);
1102 db_finalize(&s);
1103 p->idMsg = db_last_insert_rowid();
1104
1105 /* make entries in emailbox and emailoutq */
1106
+1
--- src/url.c
+++ src/url.c
@@ -532,10 +532,11 @@
532532
zSep = "&";
533533
}
534534
if( zName1 && zValue1 ){
535535
blob_appendf(&p->url, "%s%s", zSep, zName1);
536536
if( zValue1[0] ) blob_appendf(&p->url, "=%T", zValue1);
537
+ zSep = "&";
537538
}
538539
if( zName2 && zValue2 ){
539540
blob_appendf(&p->url, "%s%s", zSep, zName2);
540541
if( zValue2[0] ) blob_appendf(&p->url, "=%T", zValue2);
541542
}
542543
--- src/url.c
+++ src/url.c
@@ -532,10 +532,11 @@
532 zSep = "&";
533 }
534 if( zName1 && zValue1 ){
535 blob_appendf(&p->url, "%s%s", zSep, zName1);
536 if( zValue1[0] ) blob_appendf(&p->url, "=%T", zValue1);
 
537 }
538 if( zName2 && zValue2 ){
539 blob_appendf(&p->url, "%s%s", zSep, zName2);
540 if( zValue2[0] ) blob_appendf(&p->url, "=%T", zValue2);
541 }
542
--- src/url.c
+++ src/url.c
@@ -532,10 +532,11 @@
532 zSep = "&";
533 }
534 if( zName1 && zValue1 ){
535 blob_appendf(&p->url, "%s%s", zSep, zName1);
536 if( zValue1[0] ) blob_appendf(&p->url, "=%T", zValue1);
537 zSep = "&";
538 }
539 if( zName2 && zValue2 ){
540 blob_appendf(&p->url, "%s%s", zSep, zName2);
541 if( zValue2[0] ) blob_appendf(&p->url, "=%T", zValue2);
542 }
543
+22 -1
--- src/webmail.c
+++ src/webmail.c
@@ -392,17 +392,18 @@
392392
const char *zUser /* User who owns it, or NULL if does not matter */
393393
){
394394
Blob sql;
395395
Stmt q;
396396
int eState = -1;
397
+ int eTranscript = 0;
397398
char zENum[30];
398399
style_submenu_element("Index", "%s", url_render(pUrl,"id",0,0,0));
399400
webmail_f_submenu();
400401
blob_init(&sql, 0, 0);
401402
db_begin_transaction();
402403
blob_append_sql(&sql,
403
- "SELECT decompress(etxt), estate"
404
+ "SELECT decompress(etxt), estate, emailblob.ets"
404405
" FROM emailblob, emailbox"
405406
" WHERE emailid=emsgid AND ebid=%d",
406407
emailid
407408
);
408409
if( zUser ) blob_append_sql(&sql, " AND euser=%Q", zUser);
@@ -411,10 +412,11 @@
411412
style_header("Message %d",emailid);
412413
if( db_step(&q)==SQLITE_ROW ){
413414
Blob msg = db_column_text_as_blob(&q, 0);
414415
int eFormat = atoi(PD("f","0"));
415416
eState = db_column_int(&q, 1);
417
+ eTranscript = db_column_int(&q, 2);
416418
if( eFormat==2 ){
417419
@ <pre>%h(db_column_text(&q, 0))</pre>
418420
}else{
419421
EmailToc *p = emailtoc_from_email(&msg);
420422
int i, j;
@@ -458,10 +460,29 @@
458460
@ <pre>%h(p->aBody[i].zContent)</pre>
459461
}
460462
}
461463
}
462464
db_finalize(&q);
465
+
466
+ /* Optionally show the SMTP transcript */
467
+ if( eTranscript>0 ){
468
+ if( P("ts")==0 ){
469
+ sqlite3_snprintf(sizeof(zENum), zENum, "%d", emailid);
470
+ style_submenu_element("SMTP Transcript","%s",
471
+ url_render(pUrl, "ts", "1", "id", zENum));
472
+ }else{
473
+ db_prepare(&q,
474
+ "SELECT decompress(etxt) FROM emailblob WHERE emailid=%d", eTranscript
475
+ );
476
+ if( db_step(&q)==SQLITE_ROW ){
477
+ const char *zTranscript = db_column_text(&q, 0);
478
+ @ <hr>
479
+ @ <pre>%h(zTranscript)</pre>
480
+ }
481
+ db_finalize(&q);
482
+ }
483
+ }
463484
464485
if( eState==0 ){
465486
/* If is message is currently Unread, change it to Read */
466487
blob_append_sql(&sql,
467488
"UPDATE emailbox SET estate=1 "
468489
--- src/webmail.c
+++ src/webmail.c
@@ -392,17 +392,18 @@
392 const char *zUser /* User who owns it, or NULL if does not matter */
393 ){
394 Blob sql;
395 Stmt q;
396 int eState = -1;
 
397 char zENum[30];
398 style_submenu_element("Index", "%s", url_render(pUrl,"id",0,0,0));
399 webmail_f_submenu();
400 blob_init(&sql, 0, 0);
401 db_begin_transaction();
402 blob_append_sql(&sql,
403 "SELECT decompress(etxt), estate"
404 " FROM emailblob, emailbox"
405 " WHERE emailid=emsgid AND ebid=%d",
406 emailid
407 );
408 if( zUser ) blob_append_sql(&sql, " AND euser=%Q", zUser);
@@ -411,10 +412,11 @@
411 style_header("Message %d",emailid);
412 if( db_step(&q)==SQLITE_ROW ){
413 Blob msg = db_column_text_as_blob(&q, 0);
414 int eFormat = atoi(PD("f","0"));
415 eState = db_column_int(&q, 1);
 
416 if( eFormat==2 ){
417 @ <pre>%h(db_column_text(&q, 0))</pre>
418 }else{
419 EmailToc *p = emailtoc_from_email(&msg);
420 int i, j;
@@ -458,10 +460,29 @@
458 @ <pre>%h(p->aBody[i].zContent)</pre>
459 }
460 }
461 }
462 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463
464 if( eState==0 ){
465 /* If is message is currently Unread, change it to Read */
466 blob_append_sql(&sql,
467 "UPDATE emailbox SET estate=1 "
468
--- src/webmail.c
+++ src/webmail.c
@@ -392,17 +392,18 @@
392 const char *zUser /* User who owns it, or NULL if does not matter */
393 ){
394 Blob sql;
395 Stmt q;
396 int eState = -1;
397 int eTranscript = 0;
398 char zENum[30];
399 style_submenu_element("Index", "%s", url_render(pUrl,"id",0,0,0));
400 webmail_f_submenu();
401 blob_init(&sql, 0, 0);
402 db_begin_transaction();
403 blob_append_sql(&sql,
404 "SELECT decompress(etxt), estate, emailblob.ets"
405 " FROM emailblob, emailbox"
406 " WHERE emailid=emsgid AND ebid=%d",
407 emailid
408 );
409 if( zUser ) blob_append_sql(&sql, " AND euser=%Q", zUser);
@@ -411,10 +412,11 @@
412 style_header("Message %d",emailid);
413 if( db_step(&q)==SQLITE_ROW ){
414 Blob msg = db_column_text_as_blob(&q, 0);
415 int eFormat = atoi(PD("f","0"));
416 eState = db_column_int(&q, 1);
417 eTranscript = db_column_int(&q, 2);
418 if( eFormat==2 ){
419 @ <pre>%h(db_column_text(&q, 0))</pre>
420 }else{
421 EmailToc *p = emailtoc_from_email(&msg);
422 int i, j;
@@ -458,10 +460,29 @@
460 @ <pre>%h(p->aBody[i].zContent)</pre>
461 }
462 }
463 }
464 db_finalize(&q);
465
466 /* Optionally show the SMTP transcript */
467 if( eTranscript>0 ){
468 if( P("ts")==0 ){
469 sqlite3_snprintf(sizeof(zENum), zENum, "%d", emailid);
470 style_submenu_element("SMTP Transcript","%s",
471 url_render(pUrl, "ts", "1", "id", zENum));
472 }else{
473 db_prepare(&q,
474 "SELECT decompress(etxt) FROM emailblob WHERE emailid=%d", eTranscript
475 );
476 if( db_step(&q)==SQLITE_ROW ){
477 const char *zTranscript = db_column_text(&q, 0);
478 @ <hr>
479 @ <pre>%h(zTranscript)</pre>
480 }
481 db_finalize(&q);
482 }
483 }
484
485 if( eState==0 ){
486 /* If is message is currently Unread, change it to Read */
487 blob_append_sql(&sql,
488 "UPDATE emailbox SET estate=1 "
489

Keyboard Shortcuts

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