Fossil

Diff
Login

Diff

Differences From Artifact [8552e56d63]:

To Artifact [10571c27fb]:


300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
  /* Always in-line the javascript for the chat page */
  @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
  /* We need an onload handler to ensure that window.fossil is
     initialized before the chat init code runs. */
  @ window.addEventListener('load', function(){
  @ document.body.classList.add('chat');
  @ /*^^^for skins which add their own BODY tag */;
  // ajax_emit_js_preview_modes(0);
  // chat_emit_alert_list();
  @ }, false);
  @ </script>

  builtin_request_js("fossil.page.chatsearch.js");
  style_finish_page();
}








<
<







300
301
302
303
304
305
306


307
308
309
310
311
312
313
  /* Always in-line the javascript for the chat page */
  @ <script nonce="%h(style_nonce())">/* chat.c:%d(__LINE__) */
  /* We need an onload handler to ensure that window.fossil is
     initialized before the chat init code runs. */
  @ window.addEventListener('load', function(){
  @ document.body.classList.add('chat');
  @ /*^^^for skins which add their own BODY tag */;


  @ }, false);
  @ </script>

  builtin_request_js("fossil.page.chatsearch.js");
  style_finish_page();
}

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
    if( !db_table_has_column("repository","chat","mdel") ){
      db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
    }
    db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT");
  }

  if( !db_table_exists("repository", "chatfts1") ){
    db_multi_exec( 
      "CREATE VIRTUAL TABLE chatfts1 USING fts5("
      "    xmsg, content=chat, content_rowid=msgid, tokenize=porter"
      ");"
      "CREATE TRIGGER chat_ai AFTER INSERT ON chat BEGIN "
      "  INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);"
      "END;"
      "CREATE TRIGGER chat_ad AFTER DELETE ON chat BEGIN "







|







339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
    if( !db_table_has_column("repository","chat","mdel") ){
      db_multi_exec("ALTER TABLE chat ADD COLUMN mdel INT");
    }
    db_multi_exec("ALTER TABLE chat ADD COLUMN lmtime TEXT");
  }

  if( !db_table_exists("repository", "chatfts1") ){
    db_multi_exec(
      "CREATE VIRTUAL TABLE chatfts1 USING fts5("
      "    xmsg, content=chat, content_rowid=msgid, tokenize=porter"
      ");"
      "CREATE TRIGGER chat_ai AFTER INSERT ON chat BEGIN "
      "  INSERT INTO chatfts1(rowid, xmsg) VALUES(new.msgid, new.xmsg);"
      "END;"
      "CREATE TRIGGER chat_ad AFTER DELETE ON chat BEGIN "
788
789
790
791
792
793
794

795
796
797
798
799
800
801
802









803
804
805
806
807
808
809
810
811
    chat_emit_permissions_error(1);
    return;
  }
  chat_create_tables();
  cgi_set_content_type("application/json");

  if( zQuery[0] ){

    iMax = db_int64(0, "SELECT max(msgid) FROM chat");
    iMin = db_int64(0, "SELECT min(msgid) FROM chat");
    blob_append_sql(&sql,
        "SELECT * FROM ("
        "SELECT c.msgid, datetime(c.mtime), c.xfrom, "
        "  highlight(chatfts1, 0, '<span class=match>', '</span>'), "
        "  octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime"
        "  FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid "









        "  ORDER BY f.rowid DESC LIMIT %d"
        ") ORDER BY 1 ASC", zQuery, nLimit
    );
  }else{
    blob_append_sql(&sql,
        "SELECT msgid, datetime(mtime), xfrom, "
        "  xmsg, octet_length(file), fname, fmime, mdel, lmtime"
        "  FROM chat WHERE msgid>=%d LIMIT %d",
        iFirst, nLimit







>





|

|
>
>
>
>
>
>
>
>
>

|







786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
    chat_emit_permissions_error(1);
    return;
  }
  chat_create_tables();
  cgi_set_content_type("application/json");

  if( zQuery[0] ){
    char *zChatRobot = db_get("chat-timeline-user", 0);
    iMax = db_int64(0, "SELECT max(msgid) FROM chat");
    iMin = db_int64(0, "SELECT min(msgid) FROM chat");
    blob_append_sql(&sql,
        "SELECT * FROM ("
        "SELECT c.msgid, datetime(c.mtime), c.xfrom, "
        "  highlight(chatfts1, 0, '<span class=\"match\">', '</span>'), "
        "  octet_length(c.file), c.fname, c.fmime, c.mdel, c.lmtime"
        "  FROM chatfts1(%Q) f, chat c WHERE f.rowid=c.msgid ",
        zQuery
    );
    if( zChatRobot!=0 ){
      if( zChatRobot[0]!=0 ){
        blob_append_sql(&sql, "AND c.xfrom IS NOT %Q ", zChatRobot);
      }
      fossil_free( zChatRobot );
    }
    blob_append_sql(&sql,
        "  ORDER BY f.rowid DESC LIMIT %d"
        ") ORDER BY 1 ASC", nLimit
    );
  }else{
    blob_append_sql(&sql,
        "SELECT msgid, datetime(mtime), xfrom, "
        "  xmsg, octet_length(file), fname, fmime, mdel, lmtime"
        "  FROM chat WHERE msgid>=%d LIMIT %d",
        iFirst, nLimit