Fossil SCM
Enhance the subscriber since to include the creation time and so that a new random subscriber code is set.
Commit
7e87699dcf78eb2ee625733a8c0cf64bc06f112697c1d873ca1cd6f8c4eb4d1c
Parent
22c3354dcbb7189…
1 file changed
+25
-13
+25
-13
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -345,37 +345,41 @@ | ||
| 345 | 345 | ** /config $MTIME $NAME value $VALUE |
| 346 | 346 | ** /user $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE |
| 347 | 347 | ** /shun $MTIME $UUID scom $VALUE |
| 348 | 348 | ** /reportfmt $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE |
| 349 | 349 | ** /concealed $MTIME $HASH content $VALUE |
| 350 | -** /subscriber $SMTIME $SEMAIL suname $V sdigest $V sdonotcall $V ssub $V | |
| 350 | +** /subscriber $SMTIME $SEMAIL suname $V ... | |
| 351 | 351 | */ |
| 352 | 352 | void configure_receive(const char *zName, Blob *pContent, int groupMask){ |
| 353 | 353 | int checkMask; /* Masks for which we must first check existance of tables */ |
| 354 | 354 | |
| 355 | 355 | checkMask = CONFIGSET_ALERT; |
| 356 | 356 | if( zName[0]=='/' ){ |
| 357 | 357 | /* The new format */ |
| 358 | - char *azToken[12]; | |
| 358 | + char *azToken[20]; | |
| 359 | 359 | int nToken = 0; |
| 360 | 360 | int ii, jj; |
| 361 | 361 | int thisMask; |
| 362 | 362 | Blob name, value, sql; |
| 363 | 363 | static const struct receiveType { |
| 364 | 364 | const char *zName; /* Configuration key for this table */ |
| 365 | 365 | const char *zPrimKey; /* Primary key column */ |
| 366 | 366 | const char *zMTime; /* Column holding the mtime */ |
| 367 | 367 | 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 */ | |
| 369 | 371 | } 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" }, | |
| 377 | 381 | }; |
| 378 | 382 | for(ii=0; ii<count(aType); ii++){ |
| 379 | 383 | if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break; |
| 380 | 384 | } |
| 381 | 385 | if( ii>=count(aType) ) return; |
| @@ -423,15 +427,21 @@ | ||
| 423 | 427 | blob_append_sql(&sql, "\"%w\"(\"%w\", \"%w\"", |
| 424 | 428 | &zName[1], aType[ii].zPrimKey, aType[ii].zMTime); |
| 425 | 429 | for(jj=2; jj<nToken; jj+=2){ |
| 426 | 430 | blob_append_sql(&sql, ",\"%w\"", azToken[jj]); |
| 427 | 431 | } |
| 432 | + if( aType[ii].zExtraFields ){ | |
| 433 | + blob_append_sql(&sql,",%s", aType[ii].zExtraFields/*safe-for-%s*/); | |
| 434 | + } | |
| 428 | 435 | blob_append_sql(&sql,") VALUES(%s,%s", |
| 429 | 436 | azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/); |
| 430 | 437 | for(jj=2; jj<nToken; jj+=2){ |
| 431 | 438 | blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/); |
| 432 | 439 | } |
| 440 | + if( aType[ii].zExtraVals ){ | |
| 441 | + blob_append_sql(&sql,",%s", aType[ii].zExtraVals/*safe-for-%s*/); | |
| 442 | + } | |
| 433 | 443 | db_multi_exec("%s)", blob_sql_text(&sql)); |
| 434 | 444 | if( db_changes()==0 ){ |
| 435 | 445 | blob_reset(&sql); |
| 436 | 446 | blob_append_sql(&sql, "UPDATE \"%w\" SET \"%w\"=%s", |
| 437 | 447 | &zName[1], aType[ii].zMTime, azToken[0]/*safe-for-%s*/); |
| @@ -589,21 +599,23 @@ | ||
| 589 | 599 | if( (groupMask & CONFIGSET_ALERT)!=0 |
| 590 | 600 | && db_table_exists("repository","subscriber") |
| 591 | 601 | ){ |
| 592 | 602 | db_prepare(&q, "SELECT (smtime-2440587.5)*86400," |
| 593 | 603 | " quote(semail), quote(suname), quote(sdigest)," |
| 594 | - " quote(sdonotcall), quote(ssub)" | |
| 604 | + " quote(sdonotcall), quote(ssub), quote(sctime)" | |
| 595 | 605 | " FROM subscriber WHERE sverified" |
| 596 | 606 | " AND (smtime-2440587.5)*86400>=%lld", iStart); |
| 597 | 607 | 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", | |
| 599 | 610 | db_column_int64(&q, 0), /* smtime */ |
| 600 | 611 | db_column_text(&q, 1), /* semail (PK) */ |
| 601 | 612 | db_column_text(&q, 2), /* suname */ |
| 602 | 613 | db_column_text(&q, 3), /* sdigest */ |
| 603 | 614 | 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 */ | |
| 605 | 617 | ); |
| 606 | 618 | blob_appendf(pOut, "config /subscriber %d\n%s\n", |
| 607 | 619 | blob_size(&rec), blob_str(&rec)); |
| 608 | 620 | nCard++; |
| 609 | 621 | blob_reset(&rec); |
| 610 | 622 |
| --- 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 |