Fossil SCM
/chat: added optional 'raw' URL argument to specify that the xmsg text should be returned as-is instead of HTML-izing it. This is not used by /chat but is to support Brad Harder's standalone curses-based /chat client (and similar ones).
Commit
4359f4b573048e114094b07423c598538fdd3c4685ce28e3a5a89bf60f6f9b11
Parent
b70557f69059487…
1 file changed
+13
-3
+13
-3
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -483,10 +483,15 @@ | ||
| 483 | 483 | ** needs to take care to inject them at the end of the history rather |
| 484 | 484 | ** than the same place new messages go. |
| 485 | 485 | ** |
| 486 | 486 | ** If "before" is provided, "name" is ignored. |
| 487 | 487 | ** |
| 488 | +** If "raw" is provided, the "xmsg" text is sent back as-is, in | |
| 489 | +** markdown format, rather than being HTML-ized. This is not used or | |
| 490 | +** supported by fossil's own chat client but is intended for 3rd-party | |
| 491 | +** clients. (Specifically, for Brad Harder's curses-based client.) | |
| 492 | +** | |
| 488 | 493 | ** The reply from this webpage is JSON that describes the new content. |
| 489 | 494 | ** Format of the json: |
| 490 | 495 | ** |
| 491 | 496 | ** | { |
| 492 | 497 | ** | "msgs":[ |
| @@ -542,10 +547,11 @@ | ||
| 542 | 547 | const int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 543 | 548 | int nDelay; /* Maximum delay.*/ |
| 544 | 549 | int msgid = atoi(PD("name","0")); |
| 545 | 550 | const int msgBefore = atoi(PD("before","0")); |
| 546 | 551 | int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0; |
| 552 | + const int bRaw = P("raw")!=0; | |
| 547 | 553 | Blob sql = empty_blob; |
| 548 | 554 | Stmt q1; |
| 549 | 555 | nDelay = db_get_int("chat-poll-timeout",420); /* Default about 7 minutes */ |
| 550 | 556 | login_check_credentials(); |
| 551 | 557 | if( !g.perm.Chat ) { |
| @@ -619,13 +625,17 @@ | ||
| 619 | 625 | blob_appendf(&json, "null,"); |
| 620 | 626 | } |
| 621 | 627 | blob_appendf(&json, "\"uclr\":%!j,", |
| 622 | 628 | user_color(zFrom ? zFrom : "nobody")); |
| 623 | 629 | |
| 624 | - zMsg = chat_format_to_html(zRawMsg ? zRawMsg : ""); | |
| 625 | - blob_appendf(&json, "\"xmsg\":%!j,", zMsg); | |
| 626 | - fossil_free(zMsg); | |
| 630 | + if(bRaw){ | |
| 631 | + blob_appendf(&json, "\"xmsg\":%!j,", zRawMsg); | |
| 632 | + }else{ | |
| 633 | + zMsg = chat_format_to_html(zRawMsg ? zRawMsg : ""); | |
| 634 | + blob_appendf(&json, "\"xmsg\":%!j,", zMsg); | |
| 635 | + fossil_free(zMsg); | |
| 636 | + } | |
| 627 | 637 | |
| 628 | 638 | if( nByte==0 ){ |
| 629 | 639 | blob_appendf(&json, "\"fsize\":0"); |
| 630 | 640 | }else{ |
| 631 | 641 | blob_appendf(&json, "\"fsize\":%d,\"fname\":%!j,\"fmime\":%!j", |
| 632 | 642 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -483,10 +483,15 @@ | |
| 483 | ** needs to take care to inject them at the end of the history rather |
| 484 | ** than the same place new messages go. |
| 485 | ** |
| 486 | ** If "before" is provided, "name" is ignored. |
| 487 | ** |
| 488 | ** The reply from this webpage is JSON that describes the new content. |
| 489 | ** Format of the json: |
| 490 | ** |
| 491 | ** | { |
| 492 | ** | "msgs":[ |
| @@ -542,10 +547,11 @@ | |
| 542 | const int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 543 | int nDelay; /* Maximum delay.*/ |
| 544 | int msgid = atoi(PD("name","0")); |
| 545 | const int msgBefore = atoi(PD("before","0")); |
| 546 | int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0; |
| 547 | Blob sql = empty_blob; |
| 548 | Stmt q1; |
| 549 | nDelay = db_get_int("chat-poll-timeout",420); /* Default about 7 minutes */ |
| 550 | login_check_credentials(); |
| 551 | if( !g.perm.Chat ) { |
| @@ -619,13 +625,17 @@ | |
| 619 | blob_appendf(&json, "null,"); |
| 620 | } |
| 621 | blob_appendf(&json, "\"uclr\":%!j,", |
| 622 | user_color(zFrom ? zFrom : "nobody")); |
| 623 | |
| 624 | zMsg = chat_format_to_html(zRawMsg ? zRawMsg : ""); |
| 625 | blob_appendf(&json, "\"xmsg\":%!j,", zMsg); |
| 626 | fossil_free(zMsg); |
| 627 | |
| 628 | if( nByte==0 ){ |
| 629 | blob_appendf(&json, "\"fsize\":0"); |
| 630 | }else{ |
| 631 | blob_appendf(&json, "\"fsize\":%d,\"fname\":%!j,\"fmime\":%!j", |
| 632 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -483,10 +483,15 @@ | |
| 483 | ** needs to take care to inject them at the end of the history rather |
| 484 | ** than the same place new messages go. |
| 485 | ** |
| 486 | ** If "before" is provided, "name" is ignored. |
| 487 | ** |
| 488 | ** If "raw" is provided, the "xmsg" text is sent back as-is, in |
| 489 | ** markdown format, rather than being HTML-ized. This is not used or |
| 490 | ** supported by fossil's own chat client but is intended for 3rd-party |
| 491 | ** clients. (Specifically, for Brad Harder's curses-based client.) |
| 492 | ** |
| 493 | ** The reply from this webpage is JSON that describes the new content. |
| 494 | ** Format of the json: |
| 495 | ** |
| 496 | ** | { |
| 497 | ** | "msgs":[ |
| @@ -542,10 +547,11 @@ | |
| 547 | const int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 548 | int nDelay; /* Maximum delay.*/ |
| 549 | int msgid = atoi(PD("name","0")); |
| 550 | const int msgBefore = atoi(PD("before","0")); |
| 551 | int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0; |
| 552 | const int bRaw = P("raw")!=0; |
| 553 | Blob sql = empty_blob; |
| 554 | Stmt q1; |
| 555 | nDelay = db_get_int("chat-poll-timeout",420); /* Default about 7 minutes */ |
| 556 | login_check_credentials(); |
| 557 | if( !g.perm.Chat ) { |
| @@ -619,13 +625,17 @@ | |
| 625 | blob_appendf(&json, "null,"); |
| 626 | } |
| 627 | blob_appendf(&json, "\"uclr\":%!j,", |
| 628 | user_color(zFrom ? zFrom : "nobody")); |
| 629 | |
| 630 | if(bRaw){ |
| 631 | blob_appendf(&json, "\"xmsg\":%!j,", zRawMsg); |
| 632 | }else{ |
| 633 | zMsg = chat_format_to_html(zRawMsg ? zRawMsg : ""); |
| 634 | blob_appendf(&json, "\"xmsg\":%!j,", zMsg); |
| 635 | fossil_free(zMsg); |
| 636 | } |
| 637 | |
| 638 | if( nByte==0 ){ |
| 639 | blob_appendf(&json, "\"fsize\":0"); |
| 640 | }else{ |
| 641 | blob_appendf(&json, "\"fsize\":%d,\"fname\":%!j,\"fmime\":%!j", |
| 642 |