Fossil

Check-in [7e87699d]
Login

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

Overview
Comment:Enhance the subscriber since to include the creation time and so that a new random subscriber code is set.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:7e87699dcf78eb2ee625733a8c0cf64bc06f112697c1d873ca1cd6f8c4eb4d1c
User & Date: drh 2018-06-25 16:14:51
Context
2018-06-25
16:19
Fix harmless compiler warnings. Also remove the "ago" text from the "Last Change" column in the subscriber list webpage. check-in: 69d332ff user: drh tags: trunk
16:14
Enhance the subscriber since to include the creation time and so that a new random subscriber code is set. check-in: 7e87699d user: drh tags: trunk
15:56
Add the ability to transfer subscriber information using the "fossil config sync alert" command. check-in: 22c3354d user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/configure.c.

343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368


369
370
371
372
373
374
375
376


377
378
379
380
381
382
383
...
421
422
423
424
425
426
427



428
429
430
431
432



433
434
435
436
437
438
439
...
587
588
589
590
591
592
593
594
595
596
597

598
599
600
601
602
603
604

605
606
607
608
609
610
611
**    NAME        CONTENT
**    -------     -----------------------------------------------------------
**    /config     $MTIME $NAME value $VALUE
**    /user       $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE
**    /shun       $MTIME $UUID scom $VALUE
**    /reportfmt  $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE
**    /concealed  $MTIME $HASH content $VALUE
**    /subscriber $SMTIME $SEMAIL suname $V sdigest $V sdonotcall $V ssub $V
*/
void configure_receive(const char *zName, Blob *pContent, int groupMask){
  int checkMask;   /* Masks for which we must first check existance of tables */

  checkMask = CONFIGSET_ALERT;
  if( zName[0]=='/' ){
    /* The new format */
    char *azToken[12];
    int nToken = 0;
    int ii, jj;
    int thisMask;
    Blob name, value, sql;
    static const struct receiveType {
      const char *zName;         /* Configuration key for this table */
      const char *zPrimKey;      /* Primary key column */
      const char *zMTime;        /* Column holding the mtime */
      int nField;                /* Number of data fields */
      const char *azField[4];    /* Names of the data fields */


    } aType[] = {
      { "/config",    "name",  "mtime", 1, { "value", 0, 0, 0 }             },
      { "@user",      "login", "mtime", 4, { "pw", "cap", "info", "photo" }  },
      { "@shun",      "uuid",  "mtime", 1, { "scom", 0, 0, 0 }               },
      { "@reportfmt", "title", "mtime", 3, { "owner", "cols", "sqlcode", 0 } },
      { "@concealed", "hash",  "mtime", 1, { "content", 0, 0, 0 }            },
      { "@subscriber","semail","smtime",4, { "suname","sdigest",
                                             "sdonotcall","ssub"}            },


    };
    for(ii=0; ii<count(aType); ii++){
      if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break;
    }
    if( ii>=count(aType) ) return;
    while( blob_token(pContent, &name) && blob_sqltoken(pContent, &value) ){
      char *z = blob_terminate(&name);
................................................................................
      blob_append_sql(&sql, "INSERT OR IGNORE INTO ");
    }
    blob_append_sql(&sql, "\"%w\"(\"%w\", \"%w\"",
         &zName[1], aType[ii].zPrimKey, aType[ii].zMTime);
    for(jj=2; jj<nToken; jj+=2){
       blob_append_sql(&sql, ",\"%w\"", azToken[jj]);
    }



    blob_append_sql(&sql,") VALUES(%s,%s",
       azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/);
    for(jj=2; jj<nToken; jj+=2){
       blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/);
    }



    db_multi_exec("%s)", blob_sql_text(&sql));
    if( db_changes()==0 ){
      blob_reset(&sql);
      blob_append_sql(&sql, "UPDATE \"%w\" SET \"%w\"=%s",
                      &zName[1], aType[ii].zMTime, azToken[0]/*safe-for-%s*/);
      for(jj=2; jj<nToken; jj+=2){
        blob_append_sql(&sql, ", \"%w\"=%s",
................................................................................
    db_finalize(&q);
  }
  if( (groupMask & CONFIGSET_ALERT)!=0
   && db_table_exists("repository","subscriber")
  ){
    db_prepare(&q, "SELECT (smtime-2440587.5)*86400,"
                   " quote(semail), quote(suname), quote(sdigest),"
                   " quote(sdonotcall), quote(ssub)"
                   " FROM subscriber WHERE sverified"
                   " AND (smtime-2440587.5)*86400>=%lld", iStart);
    while( db_step(&q)==SQLITE_ROW ){

      blob_appendf(&rec,"%lld %s suname %s sdigest %s sdonotcall %s ssub %s",
        db_column_int64(&q, 0), /* smtime */
        db_column_text(&q, 1),  /* semail (PK) */
        db_column_text(&q, 2),  /* suname */
        db_column_text(&q, 3),  /* sdigest */
        db_column_text(&q, 4),  /* sdonotcall */
        db_column_text(&q, 5)   /* ssub */

      );
      blob_appendf(pOut, "config /subscriber %d\n%s\n",
                   blob_size(&rec), blob_str(&rec));
      nCard++;
      blob_reset(&rec);
    }
    db_finalize(&q);







|







|









|
>
>

|
|
|
|
|
|
|
>
>







 







>
>
>





>
>
>







 







|



>
|





|
>







343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
...
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
**    NAME        CONTENT
**    -------     -----------------------------------------------------------
**    /config     $MTIME $NAME value $VALUE
**    /user       $MTIME $LOGIN pw $VALUE cap $VALUE info $VALUE photo $VALUE
**    /shun       $MTIME $UUID scom $VALUE
**    /reportfmt  $MTIME $TITLE owner $VALUE cols $VALUE sqlcode $VALUE
**    /concealed  $MTIME $HASH content $VALUE
**    /subscriber $SMTIME $SEMAIL suname $V ...
*/
void configure_receive(const char *zName, Blob *pContent, int groupMask){
  int checkMask;   /* Masks for which we must first check existance of tables */

  checkMask = CONFIGSET_ALERT;
  if( zName[0]=='/' ){
    /* The new format */
    char *azToken[20];
    int nToken = 0;
    int ii, jj;
    int thisMask;
    Blob name, value, sql;
    static const struct receiveType {
      const char *zName;         /* Configuration key for this table */
      const char *zPrimKey;      /* Primary key column */
      const char *zMTime;        /* Column holding the mtime */
      int nField;                /* Number of data fields */
      const char *azField[5];    /* Names of the data fields */
      const char *zExtraFields;  /* Extra field names */
      const char *zExtraVals;    /* Values for the extra fields */
    } aType[] = {
      { "/config",    "name",  "mtime", 1, { "value", 0, 0, 0 }, 0, 0        },
      { "@user",      "login", "mtime", 4, { "pw","cap","info","photo"},0,0  },
      { "@shun",      "uuid",  "mtime", 1, { "scom", 0, 0, 0 },0,0           },
      { "@reportfmt", "title", "mtime", 3, { "owner","cols","sqlcode",0},0,0 },
      { "@concealed", "hash",  "mtime", 1, { "content", 0, 0, 0 },0,0        },
      { "@subscriber","semail","smtime",5,
         { "suname","sdigest","sdonotcall","ssub","sctime"},
         "subscriberCode,sverified", 
         "randomblob(32),1"                                                  },
    };
    for(ii=0; ii<count(aType); ii++){
      if( fossil_strcmp(&aType[ii].zName[1],&zName[1])==0 ) break;
    }
    if( ii>=count(aType) ) return;
    while( blob_token(pContent, &name) && blob_sqltoken(pContent, &value) ){
      char *z = blob_terminate(&name);
................................................................................
      blob_append_sql(&sql, "INSERT OR IGNORE INTO ");
    }
    blob_append_sql(&sql, "\"%w\"(\"%w\", \"%w\"",
         &zName[1], aType[ii].zPrimKey, aType[ii].zMTime);
    for(jj=2; jj<nToken; jj+=2){
       blob_append_sql(&sql, ",\"%w\"", azToken[jj]);
    }
    if( aType[ii].zExtraFields ){
      blob_append_sql(&sql,",%s", aType[ii].zExtraFields/*safe-for-%s*/);
    }
    blob_append_sql(&sql,") VALUES(%s,%s",
       azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/);
    for(jj=2; jj<nToken; jj+=2){
       blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/);
    }
    if( aType[ii].zExtraVals ){
      blob_append_sql(&sql,",%s", aType[ii].zExtraVals/*safe-for-%s*/);
    }
    db_multi_exec("%s)", blob_sql_text(&sql));
    if( db_changes()==0 ){
      blob_reset(&sql);
      blob_append_sql(&sql, "UPDATE \"%w\" SET \"%w\"=%s",
                      &zName[1], aType[ii].zMTime, azToken[0]/*safe-for-%s*/);
      for(jj=2; jj<nToken; jj+=2){
        blob_append_sql(&sql, ", \"%w\"=%s",
................................................................................
    db_finalize(&q);
  }
  if( (groupMask & CONFIGSET_ALERT)!=0
   && db_table_exists("repository","subscriber")
  ){
    db_prepare(&q, "SELECT (smtime-2440587.5)*86400,"
                   " quote(semail), quote(suname), quote(sdigest),"
                   " quote(sdonotcall), quote(ssub), quote(sctime)"
                   " FROM subscriber WHERE sverified"
                   " AND (smtime-2440587.5)*86400>=%lld", iStart);
    while( db_step(&q)==SQLITE_ROW ){
      blob_appendf(&rec,
        "%lld %s suname %s sdigest %s sdonotcall %s ssub %s sctime %s",
        db_column_int64(&q, 0), /* smtime */
        db_column_text(&q, 1),  /* semail (PK) */
        db_column_text(&q, 2),  /* suname */
        db_column_text(&q, 3),  /* sdigest */
        db_column_text(&q, 4),  /* sdonotcall */
        db_column_text(&q, 5),  /* ssub */
        db_column_text(&q, 6)   /* sctime */
      );
      blob_appendf(pOut, "config /subscriber %d\n%s\n",
                   blob_size(&rec), blob_str(&rec));
      nCard++;
      blob_reset(&rec);
    }
    db_finalize(&q);