Fossil

Diff
Login

Diff

Differences From Artifact [b58db78408]:

To Artifact [f26b86cd03]:


233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
  char * zTime = cgi_iso8601_datestamp();
  cgi_set_content_type("application/json");
  if(fAsMessageList){
    CX("{\"msgs\":[{");
  }else{
    CX("{");
  }
  CX("\"isError\": true, \"xfrom\": \"fossil\",");
  CX("\"mtime\": %!j, \"lmtime\": %!j,", zTime, zTime);
  CX("\"xmsg\": \"Missing permissions or not logged in. "
     "Try <a href='%R/login?g=%R/chat'>logging in</a>.\"");
  if(fAsMessageList){
    CX("}]}");
  }else{
    CX("}");







|







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
  char * zTime = cgi_iso8601_datestamp();
  cgi_set_content_type("application/json");
  if(fAsMessageList){
    CX("{\"msgs\":[{");
  }else{
    CX("{");
  }
  CX("\"isError\": true, \"xfrom\": null,");
  CX("\"mtime\": %!j, \"lmtime\": %!j,", zTime, zTime);
  CX("\"xmsg\": \"Missing permissions or not logged in. "
     "Try <a href='%R/login?g=%R/chat'>logging in</a>.\"");
  if(fAsMessageList){
    CX("}]}");
  }else{
    CX("}");
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
** permissions cannot be verified because their login cookie expired, the
** request returns a slightly modified structure:
**
** |    {
** |      "msgs":[
** |        {
** |          "isError": true,
** |          "xfrom": "fossil",
** |          "xmsg": "error details"
** |          "mtime": as above,
** |          "ltime": same as mtime
** |        }
** |      ]
** |    }
**







|







464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
** permissions cannot be verified because their login cookie expired, the
** request returns a slightly modified structure:
**
** |    {
** |      "msgs":[
** |        {
** |          "isError": true,
** |          "xfrom": null,
** |          "xmsg": "error details"
** |          "mtime": as above,
** |          "ltime": same as mtime
** |        }
** |      ]
** |    }
**
674
675
676
677
678
679
680
















681
682
683
684
685
686
687
void chat_ping_webpage(void){
  const char *zIpAddr = PD("REMOTE_ADDR","nil");
  if( cgi_is_loopback(zIpAddr) ){
    cgi_append_header("Access-Control-Allow-Origin: *\r\n");
    fputc(7, stderr);
  }
}

















/*
** COMMAND: chat
**
** Usage: %fossil chat ?URL?
**
** Bring up a window to the chatroom feature of the Fossil repository







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
void chat_ping_webpage(void){
  const char *zIpAddr = PD("REMOTE_ADDR","nil");
  if( cgi_is_loopback(zIpAddr) ){
    cgi_append_header("Access-Control-Allow-Origin: *\r\n");
    fputc(7, stderr);
  }
}

/*
** WEBPAGE: chat-audio-received
**
** Responds with an audio stream suitable for use as a /chat
** new-message-arrived notification.
*/
void chat_audio_alert(void){
  Blob audio = empty_blob;
  int n = 0;
  const char * zAudio =
    (const char *)builtin_file("sounds/chat-received.wav", &n);
  blob_init(&audio, zAudio, n);
  cgi_set_content_type("audio/wav");
  cgi_set_content(&audio);  
}

/*
** COMMAND: chat
**
** Usage: %fossil chat ?URL?
**
** Bring up a window to the chatroom feature of the Fossil repository