Fossil SCM

Enhance the subscriber since to include the creation time and so that a new random subscriber code is set.

drh 2018-06-25 16:14 trunk
Commit 7e87699dcf78eb2ee625733a8c0cf64bc06f112697c1d873ca1cd6f8c4eb4d1c
1 file changed +25 -13
+25 -13
--- src/configure.c
+++ src/configure.c
@@ -345,37 +345,41 @@
345345
** /config $MTIME $NAME value $VALUE
346346
** /user $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE
347347
** /shun $MTIME $UUID scom $VALUE
348348
** /reportfmt $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE
349349
** /concealed $MTIME $HASH content $VALUE
350
-** /subscriber $SMTIME $SEMAIL suname $V sdigest $V sdonotcall $V ssub $V
350
+** /subscriber $SMTIME $SEMAIL suname $V ...
351351
*/
352352
void configure_receive(const char *zName, Blob *pContent, int groupMask){
353353
int checkMask; /* Masks for which we must first check existance of tables */
354354
355355
checkMask = CONFIGSET_ALERT;
356356
if( zName[0]=='/' ){
357357
/* The new format */
358
- char *azToken[12];
358
+ char *azToken[20];
359359
int nToken = 0;
360360
int ii, jj;
361361
int thisMask;
362362
Blob name, value, sql;
363363
static const struct receiveType {
364364
const char *zName; /* Configuration key for this table */
365365
const char *zPrimKey; /* Primary key column */
366366
const char *zMTime; /* Column holding the mtime */
367367
int nField; /* Number of data fields */
368
- const char *azField[4]; /* Names of the data fields */
368
+ const char *azField[5]; /* Names of the data fields */
369
+ const char *zExtraFields; /* Extra field names */
370
+ const char *zExtraVals; /* Values for the extra fields */
369371
} aType[] = {
370
- { "/config", "name", "mtime", 1, { "value", 0, 0, 0 } },
371
- { "@user", "login", "mtime", 4, { "pw", "cap", "info", "photo" } },
372
- { "@shun", "uuid", "mtime", 1, { "scom", 0, 0, 0 } },
373
- { "@reportfmt", "title", "mtime", 3, { "owner", "cols", "sqlcode", 0 } },
374
- { "@concealed", "hash", "mtime", 1, { "content", 0, 0, 0 } },
375
- { "@subscriber","semail","smtime",4, { "suname","sdigest",
376
- "sdonotcall","ssub"} },
372
+ { "/config", "name", "mtime", 1, { "value", 0, 0, 0 }, 0, 0 },
373
+ { "@user", "login", "mtime", 4, { "pw","cap","info","photo"},0,0 },
374
+ { "@shun", "uuid", "mtime", 1, { "scom", 0, 0, 0 },0,0 },
375
+ { "@reportfmt", "title", "mtime", 3, { "owner","cols","sqlcode",0},0,0 },
376
+ { "@concealed", "hash", "mtime", 1, { "content", 0, 0, 0 },0,0 },
377
+ { "@subscriber","semail","smtime",5,
378
+ { "suname","sdigest","sdonotcall","ssub","sctime"},
379
+ "subscriberCode,sverified",
380
+ "randomblob(32),1" },
377381
};
378382
for(ii=0; ii<count(aType); ii++){
379383
if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break;
380384
}
381385
if( ii>=count(aType) ) return;
@@ -423,15 +427,21 @@
423427
blob_append_sql(&sql, "\"%w\"(\"%w\", \"%w\"",
424428
&zName[1], aType[ii].zPrimKey, aType[ii].zMTime);
425429
for(jj=2; jj<nToken; jj+=2){
426430
blob_append_sql(&sql, ",\"%w\"", azToken[jj]);
427431
}
432
+ if( aType[ii].zExtraFields ){
433
+ blob_append_sql(&sql,",%s", aType[ii].zExtraFields/*safe-for-%s*/);
434
+ }
428435
blob_append_sql(&sql,") VALUES(%s,%s",
429436
azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/);
430437
for(jj=2; jj<nToken; jj+=2){
431438
blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/);
432439
}
440
+ if( aType[ii].zExtraVals ){
441
+ blob_append_sql(&sql,",%s", aType[ii].zExtraVals/*safe-for-%s*/);
442
+ }
433443
db_multi_exec("%s)", blob_sql_text(&sql));
434444
if( db_changes()==0 ){
435445
blob_reset(&sql);
436446
blob_append_sql(&sql, "UPDATE \"%w\" SET \"%w\"=%s",
437447
&zName[1], aType[ii].zMTime, azToken[0]/*safe-for-%s*/);
@@ -589,21 +599,23 @@
589599
if( (groupMask & CONFIGSET_ALERT)!=0
590600
&& db_table_exists("repository","subscriber")
591601
){
592602
db_prepare(&q, "SELECT (smtime-2440587.5)*86400,"
593603
" quote(semail), quote(suname), quote(sdigest),"
594
- " quote(sdonotcall), quote(ssub)"
604
+ " quote(sdonotcall), quote(ssub), quote(sctime)"
595605
" FROM subscriber WHERE sverified"
596606
" AND (smtime-2440587.5)*86400>=%lld", iStart);
597607
while( db_step(&q)==SQLITE_ROW ){
598
- blob_appendf(&rec,"%lld %s suname %s sdigest %s sdonotcall %s ssub %s",
608
+ blob_appendf(&rec,
609
+ "%lld %s suname %s sdigest %s sdonotcall %s ssub %s sctime %s",
599610
db_column_int64(&q, 0), /* smtime */
600611
db_column_text(&q, 1), /* semail (PK) */
601612
db_column_text(&q, 2), /* suname */
602613
db_column_text(&q, 3), /* sdigest */
603614
db_column_text(&q, 4), /* sdonotcall */
604
- db_column_text(&q, 5) /* ssub */
615
+ db_column_text(&q, 5), /* ssub */
616
+ db_column_text(&q, 6) /* sctime */
605617
);
606618
blob_appendf(pOut, "config /subscriber %d\n%s\n",
607619
blob_size(&rec), blob_str(&rec));
608620
nCard++;
609621
blob_reset(&rec);
610622
--- src/configure.c
+++ src/configure.c
@@ -345,37 +345,41 @@
345 ** /config $MTIME $NAME value $VALUE
346 ** /user $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE
347 ** /shun $MTIME $UUID scom $VALUE
348 ** /reportfmt $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE
349 ** /concealed $MTIME $HASH content $VALUE
350 ** /subscriber $SMTIME $SEMAIL suname $V sdigest $V sdonotcall $V ssub $V
351 */
352 void configure_receive(const char *zName, Blob *pContent, int groupMask){
353 int checkMask; /* Masks for which we must first check existance of tables */
354
355 checkMask = CONFIGSET_ALERT;
356 if( zName[0]=='/' ){
357 /* The new format */
358 char *azToken[12];
359 int nToken = 0;
360 int ii, jj;
361 int thisMask;
362 Blob name, value, sql;
363 static const struct receiveType {
364 const char *zName; /* Configuration key for this table */
365 const char *zPrimKey; /* Primary key column */
366 const char *zMTime; /* Column holding the mtime */
367 int nField; /* Number of data fields */
368 const char *azField[4]; /* Names of the data fields */
 
 
369 } aType[] = {
370 { "/config", "name", "mtime", 1, { "value", 0, 0, 0 } },
371 { "@user", "login", "mtime", 4, { "pw", "cap", "info", "photo" } },
372 { "@shun", "uuid", "mtime", 1, { "scom", 0, 0, 0 } },
373 { "@reportfmt", "title", "mtime", 3, { "owner", "cols", "sqlcode", 0 } },
374 { "@concealed", "hash", "mtime", 1, { "content", 0, 0, 0 } },
375 { "@subscriber","semail","smtime",4, { "suname","sdigest",
376 "sdonotcall","ssub"} },
 
 
377 };
378 for(ii=0; ii<count(aType); ii++){
379 if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break;
380 }
381 if( ii>=count(aType) ) return;
@@ -423,15 +427,21 @@
423 blob_append_sql(&sql, "\"%w\"(\"%w\", \"%w\"",
424 &zName[1], aType[ii].zPrimKey, aType[ii].zMTime);
425 for(jj=2; jj<nToken; jj+=2){
426 blob_append_sql(&sql, ",\"%w\"", azToken[jj]);
427 }
 
 
 
428 blob_append_sql(&sql,") VALUES(%s,%s",
429 azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/);
430 for(jj=2; jj<nToken; jj+=2){
431 blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/);
432 }
 
 
 
433 db_multi_exec("%s)", blob_sql_text(&sql));
434 if( db_changes()==0 ){
435 blob_reset(&sql);
436 blob_append_sql(&sql, "UPDATE \"%w\" SET \"%w\"=%s",
437 &zName[1], aType[ii].zMTime, azToken[0]/*safe-for-%s*/);
@@ -589,21 +599,23 @@
589 if( (groupMask & CONFIGSET_ALERT)!=0
590 && db_table_exists("repository","subscriber")
591 ){
592 db_prepare(&q, "SELECT (smtime-2440587.5)*86400,"
593 " quote(semail), quote(suname), quote(sdigest),"
594 " quote(sdonotcall), quote(ssub)"
595 " FROM subscriber WHERE sverified"
596 " AND (smtime-2440587.5)*86400>=%lld", iStart);
597 while( db_step(&q)==SQLITE_ROW ){
598 blob_appendf(&rec,"%lld %s suname %s sdigest %s sdonotcall %s ssub %s",
 
599 db_column_int64(&q, 0), /* smtime */
600 db_column_text(&q, 1), /* semail (PK) */
601 db_column_text(&q, 2), /* suname */
602 db_column_text(&q, 3), /* sdigest */
603 db_column_text(&q, 4), /* sdonotcall */
604 db_column_text(&q, 5) /* ssub */
 
605 );
606 blob_appendf(pOut, "config /subscriber %d\n%s\n",
607 blob_size(&rec), blob_str(&rec));
608 nCard++;
609 blob_reset(&rec);
610
--- src/configure.c
+++ src/configure.c
@@ -345,37 +345,41 @@
345 ** /config $MTIME $NAME value $VALUE
346 ** /user $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE
347 ** /shun $MTIME $UUID scom $VALUE
348 ** /reportfmt $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE
349 ** /concealed $MTIME $HASH content $VALUE
350 ** /subscriber $SMTIME $SEMAIL suname $V ...
351 */
352 void configure_receive(const char *zName, Blob *pContent, int groupMask){
353 int checkMask; /* Masks for which we must first check existance of tables */
354
355 checkMask = CONFIGSET_ALERT;
356 if( zName[0]=='/' ){
357 /* The new format */
358 char *azToken[20];
359 int nToken = 0;
360 int ii, jj;
361 int thisMask;
362 Blob name, value, sql;
363 static const struct receiveType {
364 const char *zName; /* Configuration key for this table */
365 const char *zPrimKey; /* Primary key column */
366 const char *zMTime; /* Column holding the mtime */
367 int nField; /* Number of data fields */
368 const char *azField[5]; /* Names of the data fields */
369 const char *zExtraFields; /* Extra field names */
370 const char *zExtraVals; /* Values for the extra fields */
371 } aType[] = {
372 { "/config", "name", "mtime", 1, { "value", 0, 0, 0 }, 0, 0 },
373 { "@user", "login", "mtime", 4, { "pw","cap","info","photo"},0,0 },
374 { "@shun", "uuid", "mtime", 1, { "scom", 0, 0, 0 },0,0 },
375 { "@reportfmt", "title", "mtime", 3, { "owner","cols","sqlcode",0},0,0 },
376 { "@concealed", "hash", "mtime", 1, { "content", 0, 0, 0 },0,0 },
377 { "@subscriber","semail","smtime",5,
378 { "suname","sdigest","sdonotcall","ssub","sctime"},
379 "subscriberCode,sverified",
380 "randomblob(32),1" },
381 };
382 for(ii=0; ii<count(aType); ii++){
383 if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break;
384 }
385 if( ii>=count(aType) ) return;
@@ -423,15 +427,21 @@
427 blob_append_sql(&sql, "\"%w\"(\"%w\", \"%w\"",
428 &zName[1], aType[ii].zPrimKey, aType[ii].zMTime);
429 for(jj=2; jj<nToken; jj+=2){
430 blob_append_sql(&sql, ",\"%w\"", azToken[jj]);
431 }
432 if( aType[ii].zExtraFields ){
433 blob_append_sql(&sql,",%s", aType[ii].zExtraFields/*safe-for-%s*/);
434 }
435 blob_append_sql(&sql,") VALUES(%s,%s",
436 azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/);
437 for(jj=2; jj<nToken; jj+=2){
438 blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/);
439 }
440 if( aType[ii].zExtraVals ){
441 blob_append_sql(&sql,",%s", aType[ii].zExtraVals/*safe-for-%s*/);
442 }
443 db_multi_exec("%s)", blob_sql_text(&sql));
444 if( db_changes()==0 ){
445 blob_reset(&sql);
446 blob_append_sql(&sql, "UPDATE \"%w\" SET \"%w\"=%s",
447 &zName[1], aType[ii].zMTime, azToken[0]/*safe-for-%s*/);
@@ -589,21 +599,23 @@
599 if( (groupMask & CONFIGSET_ALERT)!=0
600 && db_table_exists("repository","subscriber")
601 ){
602 db_prepare(&q, "SELECT (smtime-2440587.5)*86400,"
603 " quote(semail), quote(suname), quote(sdigest),"
604 " quote(sdonotcall), quote(ssub), quote(sctime)"
605 " FROM subscriber WHERE sverified"
606 " AND (smtime-2440587.5)*86400>=%lld", iStart);
607 while( db_step(&q)==SQLITE_ROW ){
608 blob_appendf(&rec,
609 "%lld %s suname %s sdigest %s sdonotcall %s ssub %s sctime %s",
610 db_column_int64(&q, 0), /* smtime */
611 db_column_text(&q, 1), /* semail (PK) */
612 db_column_text(&q, 2), /* suname */
613 db_column_text(&q, 3), /* sdigest */
614 db_column_text(&q, 4), /* sdonotcall */
615 db_column_text(&q, 5), /* ssub */
616 db_column_text(&q, 6) /* sctime */
617 );
618 blob_appendf(pOut, "config /subscriber %d\n%s\n",
619 blob_size(&rec), blob_str(&rec));
620 nCard++;
621 blob_reset(&rec);
622

Keyboard Shortcuts

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