Fossil SCM
Use the chat-timeline-user setting when formatting results for chat searches.
Commit
02349c875d62f7016436ca8f3a52627a3d10d43da77039b018ed43921708c0a9
Parent
2a3a32edea79848…
1 file changed
+22
-5
+22
-5
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -511,19 +511,38 @@ | ||
| 511 | 511 | fossil_free(zOut); |
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /* |
| 516 | +** The SQL statement passed as the first argument should return zero or | |
| 517 | +** more rows of data, each of which represents a single message from the | |
| 518 | +** "chat" table. The rows returned should be similar to those returned | |
| 519 | +** by: | |
| 520 | +** | |
| 521 | +** SELECT msgid, | |
| 522 | +** datetime(mtime), | |
| 523 | +** xfrom, | |
| 524 | +** xmsg, | |
| 525 | +** octet_length(file)," | |
| 526 | +** fname, | |
| 527 | +** fmime, | |
| 528 | +** mdel, | |
| 529 | +** lmtime | |
| 530 | +** FROM chat; | |
| 516 | 531 | ** |
| 532 | +** This function loops through all rows returned by statement p, adding | |
| 533 | +** a record to the JSON stored in argument pJson for each. See comments | |
| 534 | +** above function chat_poll_webpage() for a description of the JSON records | |
| 535 | +** added to pJson. | |
| 517 | 536 | */ |
| 518 | 537 | static int chat_poll_rowstojson( |
| 519 | 538 | Stmt *p, /* Statement to read rows from */ |
| 520 | - const char *zChatUser, /* Current user */ | |
| 521 | 539 | int bRaw, /* True to return raw format xmsg */ |
| 522 | 540 | Blob *pJson /* Append json array entries here */ |
| 523 | 541 | ){ |
| 524 | 542 | int cnt = 0; |
| 543 | + const char *zChatUser = db_get("chat-timeline-user",0); | |
| 525 | 544 | while( db_step(p)==SQLITE_ROW ){ |
| 526 | 545 | int isWiki = 0; /* True if chat message is x-fossil-wiki */ |
| 527 | 546 | int id = db_column_int(p, 0); |
| 528 | 547 | const char *zDate = db_column_text(p, 1); |
| 529 | 548 | const char *zFrom = db_column_text(p, 2); |
| @@ -675,11 +694,10 @@ | ||
| 675 | 694 | void chat_poll_webpage(void){ |
| 676 | 695 | Blob json; /* The json to be constructed and returned */ |
| 677 | 696 | sqlite3_int64 dataVersion; /* Data version. Used for polling. */ |
| 678 | 697 | const int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 679 | 698 | int nDelay; /* Maximum delay.*/ |
| 680 | - const char *zChatUser; /* chat-timeline-user */ | |
| 681 | 699 | int msgid = atoi(PD("name","0")); |
| 682 | 700 | const int msgBefore = atoi(PD("before","0")); |
| 683 | 701 | int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0; |
| 684 | 702 | const int bRaw = P("raw")!=0; |
| 685 | 703 | |
| @@ -689,11 +707,10 @@ | ||
| 689 | 707 | login_check_credentials(); |
| 690 | 708 | if( !g.perm.Chat ) { |
| 691 | 709 | chat_emit_permissions_error(1); |
| 692 | 710 | return; |
| 693 | 711 | } |
| 694 | - zChatUser = db_get("chat-timeline-user",0); | |
| 695 | 712 | chat_create_tables(); |
| 696 | 713 | cgi_set_content_type("application/json"); |
| 697 | 714 | dataVersion = db_int64(0, "PRAGMA data_version"); |
| 698 | 715 | blob_append_sql(&sql, |
| 699 | 716 | "SELECT msgid, datetime(mtime), xfrom, xmsg, octet_length(file)," |
| @@ -729,11 +746,11 @@ | ||
| 729 | 746 | } |
| 730 | 747 | db_prepare(&q1, "%s", blob_sql_text(&sql)); |
| 731 | 748 | blob_reset(&sql); |
| 732 | 749 | blob_init(&json, "{\"msgs\":[\n", -1); |
| 733 | 750 | while( nDelay>0 ){ |
| 734 | - int cnt = chat_poll_rowstojson(&q1, zChatUser, bRaw, &json); | |
| 751 | + int cnt = chat_poll_rowstojson(&q1, bRaw, &json); | |
| 735 | 752 | if( cnt || msgBefore>0 ){ |
| 736 | 753 | break; |
| 737 | 754 | } |
| 738 | 755 | sqlite3_sleep(iDelay); nDelay--; |
| 739 | 756 | while( nDelay>0 ){ |
| @@ -809,11 +826,11 @@ | ||
| 809 | 826 | } |
| 810 | 827 | |
| 811 | 828 | db_prepare(&q1, "%s", blob_sql_text(&sql)); |
| 812 | 829 | blob_reset(&sql); |
| 813 | 830 | blob_init(&json, "{\"msgs\":[\n", -1); |
| 814 | - chat_poll_rowstojson(&q1, "", 0, &json); | |
| 831 | + chat_poll_rowstojson(&q1, 0, &json); | |
| 815 | 832 | db_finalize(&q1); |
| 816 | 833 | blob_appendf(&json, "\n], \"first\":%lld, \"last\":%lld}", iMin, iMax); |
| 817 | 834 | cgi_set_content(&json); |
| 818 | 835 | return; |
| 819 | 836 | } |
| 820 | 837 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -511,19 +511,38 @@ | |
| 511 | fossil_free(zOut); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /* |
| 516 | ** |
| 517 | */ |
| 518 | static int chat_poll_rowstojson( |
| 519 | Stmt *p, /* Statement to read rows from */ |
| 520 | const char *zChatUser, /* Current user */ |
| 521 | int bRaw, /* True to return raw format xmsg */ |
| 522 | Blob *pJson /* Append json array entries here */ |
| 523 | ){ |
| 524 | int cnt = 0; |
| 525 | while( db_step(p)==SQLITE_ROW ){ |
| 526 | int isWiki = 0; /* True if chat message is x-fossil-wiki */ |
| 527 | int id = db_column_int(p, 0); |
| 528 | const char *zDate = db_column_text(p, 1); |
| 529 | const char *zFrom = db_column_text(p, 2); |
| @@ -675,11 +694,10 @@ | |
| 675 | void chat_poll_webpage(void){ |
| 676 | Blob json; /* The json to be constructed and returned */ |
| 677 | sqlite3_int64 dataVersion; /* Data version. Used for polling. */ |
| 678 | const int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 679 | int nDelay; /* Maximum delay.*/ |
| 680 | const char *zChatUser; /* chat-timeline-user */ |
| 681 | int msgid = atoi(PD("name","0")); |
| 682 | const int msgBefore = atoi(PD("before","0")); |
| 683 | int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0; |
| 684 | const int bRaw = P("raw")!=0; |
| 685 | |
| @@ -689,11 +707,10 @@ | |
| 689 | login_check_credentials(); |
| 690 | if( !g.perm.Chat ) { |
| 691 | chat_emit_permissions_error(1); |
| 692 | return; |
| 693 | } |
| 694 | zChatUser = db_get("chat-timeline-user",0); |
| 695 | chat_create_tables(); |
| 696 | cgi_set_content_type("application/json"); |
| 697 | dataVersion = db_int64(0, "PRAGMA data_version"); |
| 698 | blob_append_sql(&sql, |
| 699 | "SELECT msgid, datetime(mtime), xfrom, xmsg, octet_length(file)," |
| @@ -729,11 +746,11 @@ | |
| 729 | } |
| 730 | db_prepare(&q1, "%s", blob_sql_text(&sql)); |
| 731 | blob_reset(&sql); |
| 732 | blob_init(&json, "{\"msgs\":[\n", -1); |
| 733 | while( nDelay>0 ){ |
| 734 | int cnt = chat_poll_rowstojson(&q1, zChatUser, bRaw, &json); |
| 735 | if( cnt || msgBefore>0 ){ |
| 736 | break; |
| 737 | } |
| 738 | sqlite3_sleep(iDelay); nDelay--; |
| 739 | while( nDelay>0 ){ |
| @@ -809,11 +826,11 @@ | |
| 809 | } |
| 810 | |
| 811 | db_prepare(&q1, "%s", blob_sql_text(&sql)); |
| 812 | blob_reset(&sql); |
| 813 | blob_init(&json, "{\"msgs\":[\n", -1); |
| 814 | chat_poll_rowstojson(&q1, "", 0, &json); |
| 815 | db_finalize(&q1); |
| 816 | blob_appendf(&json, "\n], \"first\":%lld, \"last\":%lld}", iMin, iMax); |
| 817 | cgi_set_content(&json); |
| 818 | return; |
| 819 | } |
| 820 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -511,19 +511,38 @@ | |
| 511 | fossil_free(zOut); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /* |
| 516 | ** The SQL statement passed as the first argument should return zero or |
| 517 | ** more rows of data, each of which represents a single message from the |
| 518 | ** "chat" table. The rows returned should be similar to those returned |
| 519 | ** by: |
| 520 | ** |
| 521 | ** SELECT msgid, |
| 522 | ** datetime(mtime), |
| 523 | ** xfrom, |
| 524 | ** xmsg, |
| 525 | ** octet_length(file)," |
| 526 | ** fname, |
| 527 | ** fmime, |
| 528 | ** mdel, |
| 529 | ** lmtime |
| 530 | ** FROM chat; |
| 531 | ** |
| 532 | ** This function loops through all rows returned by statement p, adding |
| 533 | ** a record to the JSON stored in argument pJson for each. See comments |
| 534 | ** above function chat_poll_webpage() for a description of the JSON records |
| 535 | ** added to pJson. |
| 536 | */ |
| 537 | static int chat_poll_rowstojson( |
| 538 | Stmt *p, /* Statement to read rows from */ |
| 539 | int bRaw, /* True to return raw format xmsg */ |
| 540 | Blob *pJson /* Append json array entries here */ |
| 541 | ){ |
| 542 | int cnt = 0; |
| 543 | const char *zChatUser = db_get("chat-timeline-user",0); |
| 544 | while( db_step(p)==SQLITE_ROW ){ |
| 545 | int isWiki = 0; /* True if chat message is x-fossil-wiki */ |
| 546 | int id = db_column_int(p, 0); |
| 547 | const char *zDate = db_column_text(p, 1); |
| 548 | const char *zFrom = db_column_text(p, 2); |
| @@ -675,11 +694,10 @@ | |
| 694 | void chat_poll_webpage(void){ |
| 695 | Blob json; /* The json to be constructed and returned */ |
| 696 | sqlite3_int64 dataVersion; /* Data version. Used for polling. */ |
| 697 | const int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 698 | int nDelay; /* Maximum delay.*/ |
| 699 | int msgid = atoi(PD("name","0")); |
| 700 | const int msgBefore = atoi(PD("before","0")); |
| 701 | int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0; |
| 702 | const int bRaw = P("raw")!=0; |
| 703 | |
| @@ -689,11 +707,10 @@ | |
| 707 | login_check_credentials(); |
| 708 | if( !g.perm.Chat ) { |
| 709 | chat_emit_permissions_error(1); |
| 710 | return; |
| 711 | } |
| 712 | chat_create_tables(); |
| 713 | cgi_set_content_type("application/json"); |
| 714 | dataVersion = db_int64(0, "PRAGMA data_version"); |
| 715 | blob_append_sql(&sql, |
| 716 | "SELECT msgid, datetime(mtime), xfrom, xmsg, octet_length(file)," |
| @@ -729,11 +746,11 @@ | |
| 746 | } |
| 747 | db_prepare(&q1, "%s", blob_sql_text(&sql)); |
| 748 | blob_reset(&sql); |
| 749 | blob_init(&json, "{\"msgs\":[\n", -1); |
| 750 | while( nDelay>0 ){ |
| 751 | int cnt = chat_poll_rowstojson(&q1, bRaw, &json); |
| 752 | if( cnt || msgBefore>0 ){ |
| 753 | break; |
| 754 | } |
| 755 | sqlite3_sleep(iDelay); nDelay--; |
| 756 | while( nDelay>0 ){ |
| @@ -809,11 +826,11 @@ | |
| 826 | } |
| 827 | |
| 828 | db_prepare(&q1, "%s", blob_sql_text(&sql)); |
| 829 | blob_reset(&sql); |
| 830 | blob_init(&json, "{\"msgs\":[\n", -1); |
| 831 | chat_poll_rowstojson(&q1, 0, &json); |
| 832 | db_finalize(&q1); |
| 833 | blob_appendf(&json, "\n], \"first\":%lld, \"last\":%lld}", iMin, iMax); |
| 834 | cgi_set_content(&json); |
| 835 | return; |
| 836 | } |
| 837 |