Fossil SCM

Fixes to search. (1) Keep forum search up-to-date. (2) Do not add items to search if they are pending moderation.

drh 2020-04-05 19:44 trunk
Commit 5e28febf2bc03d2bd7a614c4085ced2423c4764245c69e05acfae1964f952aed
+1 -1
--- src/attach.c
+++ src/attach.c
@@ -545,11 +545,11 @@
545545
cgi_redirectf("%R/wiki?name=%t", zWikiName);
546546
}
547547
return;
548548
}
549549
if( strcmp(zModAction,"approve")==0 ){
550
- moderation_approve(rid);
550
+ moderation_approve('a', rid);
551551
}
552552
}
553553
style_header("Attachment Details");
554554
style_submenu_element("Raw", "%R/artifact/%s", zUuid);
555555
if(fShowContent){
556556
--- src/attach.c
+++ src/attach.c
@@ -545,11 +545,11 @@
545 cgi_redirectf("%R/wiki?name=%t", zWikiName);
546 }
547 return;
548 }
549 if( strcmp(zModAction,"approve")==0 ){
550 moderation_approve(rid);
551 }
552 }
553 style_header("Attachment Details");
554 style_submenu_element("Raw", "%R/artifact/%s", zUuid);
555 if(fShowContent){
556
--- src/attach.c
+++ src/attach.c
@@ -545,11 +545,11 @@
545 cgi_redirectf("%R/wiki?name=%t", zWikiName);
546 }
547 return;
548 }
549 if( strcmp(zModAction,"approve")==0 ){
550 moderation_approve('a', rid);
551 }
552 }
553 style_header("Attachment Details");
554 style_submenu_element("Raw", "%R/artifact/%s", zUuid);
555 if(fShowContent){
556
+1 -1
--- src/forum.c
+++ src/forum.c
@@ -1018,11 +1018,11 @@
10181018
}
10191019
isCsrfSafe = cgi_csrf_safe(1);
10201020
if( g.perm.ModForum && isCsrfSafe ){
10211021
if( P("approve") ){
10221022
const char *zUserToTrust;
1023
- moderation_approve(fpid);
1023
+ moderation_approve('f', fpid);
10241024
if( g.perm.AdminForum
10251025
&& PB("trust")
10261026
&& (zUserToTrust = P("trustuser"))!=0
10271027
){
10281028
db_multi_exec("UPDATE user SET cap=cap||'4' "
10291029
--- src/forum.c
+++ src/forum.c
@@ -1018,11 +1018,11 @@
1018 }
1019 isCsrfSafe = cgi_csrf_safe(1);
1020 if( g.perm.ModForum && isCsrfSafe ){
1021 if( P("approve") ){
1022 const char *zUserToTrust;
1023 moderation_approve(fpid);
1024 if( g.perm.AdminForum
1025 && PB("trust")
1026 && (zUserToTrust = P("trustuser"))!=0
1027 ){
1028 db_multi_exec("UPDATE user SET cap=cap||'4' "
1029
--- src/forum.c
+++ src/forum.c
@@ -1018,11 +1018,11 @@
1018 }
1019 isCsrfSafe = cgi_csrf_safe(1);
1020 if( g.perm.ModForum && isCsrfSafe ){
1021 if( P("approve") ){
1022 const char *zUserToTrust;
1023 moderation_approve('f', fpid);
1024 if( g.perm.AdminForum
1025 && PB("trust")
1026 && (zUserToTrust = P("trustuser"))!=0
1027 ){
1028 db_multi_exec("UPDATE user SET cap=cap||'4' "
1029
+2 -2
--- src/info.c
+++ src/info.c
@@ -1022,11 +1022,11 @@
10221022
cgi_redirectf("%R/modreq");
10231023
/*NOTREACHED*/
10241024
}
10251025
}
10261026
if( strcmp(zModAction,"approve")==0 ){
1027
- moderation_approve(rid);
1027
+ moderation_approve('w', rid);
10281028
}
10291029
}
10301030
style_header("Update of \"%h\"", pWiki->zWikiTitle);
10311031
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
10321032
zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate);
@@ -2423,11 +2423,11 @@
24232423
cgi_redirectf("%R/modreq");
24242424
/*NOTREACHED*/
24252425
}
24262426
}
24272427
if( strcmp(zModAction,"approve")==0 ){
2428
- moderation_approve(rid);
2428
+ moderation_approve('t', rid);
24292429
}
24302430
}
24312431
zTktTitle = db_table_has_column("repository", "ticket", "title" )
24322432
? db_text("(No title)",
24332433
"SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
24342434
--- src/info.c
+++ src/info.c
@@ -1022,11 +1022,11 @@
1022 cgi_redirectf("%R/modreq");
1023 /*NOTREACHED*/
1024 }
1025 }
1026 if( strcmp(zModAction,"approve")==0 ){
1027 moderation_approve(rid);
1028 }
1029 }
1030 style_header("Update of \"%h\"", pWiki->zWikiTitle);
1031 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1032 zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate);
@@ -2423,11 +2423,11 @@
2423 cgi_redirectf("%R/modreq");
2424 /*NOTREACHED*/
2425 }
2426 }
2427 if( strcmp(zModAction,"approve")==0 ){
2428 moderation_approve(rid);
2429 }
2430 }
2431 zTktTitle = db_table_has_column("repository", "ticket", "title" )
2432 ? db_text("(No title)",
2433 "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
2434
--- src/info.c
+++ src/info.c
@@ -1022,11 +1022,11 @@
1022 cgi_redirectf("%R/modreq");
1023 /*NOTREACHED*/
1024 }
1025 }
1026 if( strcmp(zModAction,"approve")==0 ){
1027 moderation_approve('w', rid);
1028 }
1029 }
1030 style_header("Update of \"%h\"", pWiki->zWikiTitle);
1031 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1032 zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate);
@@ -2423,11 +2423,11 @@
2423 cgi_redirectf("%R/modreq");
2424 /*NOTREACHED*/
2425 }
2426 }
2427 if( strcmp(zModAction,"approve")==0 ){
2428 moderation_approve('t', rid);
2429 }
2430 }
2431 zTktTitle = db_table_has_column("repository", "ticket", "title" )
2432 ? db_text("(No title)",
2433 "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
2434
+3 -1
--- src/manifest.c
+++ src/manifest.c
@@ -2059,19 +2059,20 @@
20592059
return c;
20602060
}
20612061
20622062
/*
20632063
** Scan artifact rid/pContent to see if it is a control artifact of
2064
-** any key:
2064
+** any type:
20652065
**
20662066
** * Manifest
20672067
** * Control
20682068
** * Wiki Page
20692069
** * Ticket Change
20702070
** * Cluster
20712071
** * Attachment
20722072
** * Event
2073
+** * Forum post
20732074
**
20742075
** If the input is a control artifact, then make appropriate entries
20752076
** in the auxiliary tables of the database in order to crosslink the
20762077
** artifact.
20772078
**
@@ -2558,10 +2559,11 @@
25582559
if( p->type==CFTYPE_FORUM ){
25592560
int froot, fprev, firt;
25602561
char *zFType;
25612562
char *zTitle;
25622563
schema_forum();
2564
+ search_doc_touch('f', rid, 0);
25632565
froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid;
25642566
fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
25652567
firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
25662568
db_multi_exec(
25672569
"REPLACE INTO forumpost(fpid,froot,fprev,firt,fmtime)"
25682570
--- src/manifest.c
+++ src/manifest.c
@@ -2059,19 +2059,20 @@
2059 return c;
2060 }
2061
2062 /*
2063 ** Scan artifact rid/pContent to see if it is a control artifact of
2064 ** any key:
2065 **
2066 ** * Manifest
2067 ** * Control
2068 ** * Wiki Page
2069 ** * Ticket Change
2070 ** * Cluster
2071 ** * Attachment
2072 ** * Event
 
2073 **
2074 ** If the input is a control artifact, then make appropriate entries
2075 ** in the auxiliary tables of the database in order to crosslink the
2076 ** artifact.
2077 **
@@ -2558,10 +2559,11 @@
2558 if( p->type==CFTYPE_FORUM ){
2559 int froot, fprev, firt;
2560 char *zFType;
2561 char *zTitle;
2562 schema_forum();
 
2563 froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid;
2564 fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
2565 firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
2566 db_multi_exec(
2567 "REPLACE INTO forumpost(fpid,froot,fprev,firt,fmtime)"
2568
--- src/manifest.c
+++ src/manifest.c
@@ -2059,19 +2059,20 @@
2059 return c;
2060 }
2061
2062 /*
2063 ** Scan artifact rid/pContent to see if it is a control artifact of
2064 ** any type:
2065 **
2066 ** * Manifest
2067 ** * Control
2068 ** * Wiki Page
2069 ** * Ticket Change
2070 ** * Cluster
2071 ** * Attachment
2072 ** * Event
2073 ** * Forum post
2074 **
2075 ** If the input is a control artifact, then make appropriate entries
2076 ** in the auxiliary tables of the database in order to crosslink the
2077 ** artifact.
2078 **
@@ -2558,10 +2559,11 @@
2559 if( p->type==CFTYPE_FORUM ){
2560 int froot, fprev, firt;
2561 char *zFType;
2562 char *zTitle;
2563 schema_forum();
2564 search_doc_touch('f', rid, 0);
2565 froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid;
2566 fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
2567 firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
2568 db_multi_exec(
2569 "REPLACE INTO forumpost(fpid,froot,fprev,firt,fmtime)"
2570
+3 -2
--- src/moderate.c
+++ src/moderate.c
@@ -147,21 +147,22 @@
147147
}
148148
149149
/*
150150
** Approve an object held for moderation.
151151
*/
152
-void moderation_approve(int rid){
152
+void moderation_approve(char class, int rid){
153153
if( !moderation_pending(rid) ) return;
154154
db_begin_transaction();
155155
db_multi_exec(
156156
"DELETE FROM private WHERE rid=%d;"
157157
"INSERT OR IGNORE INTO unclustered VALUES(%d);"
158158
"INSERT OR IGNORE INTO unsent VALUES(%d);",
159159
rid, rid, rid
160160
);
161161
db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
162
- admin_log("Approved moderation of rid %d.", rid);
162
+ admin_log("Approved moderation of rid %c-%d.", class, rid);
163
+ if( class!='a' ) search_doc_touch(class, rid, 0);
163164
db_end_transaction(0);
164165
}
165166
166167
/*
167168
** WEBPAGE: modreq
168169
--- src/moderate.c
+++ src/moderate.c
@@ -147,21 +147,22 @@
147 }
148
149 /*
150 ** Approve an object held for moderation.
151 */
152 void moderation_approve(int rid){
153 if( !moderation_pending(rid) ) return;
154 db_begin_transaction();
155 db_multi_exec(
156 "DELETE FROM private WHERE rid=%d;"
157 "INSERT OR IGNORE INTO unclustered VALUES(%d);"
158 "INSERT OR IGNORE INTO unsent VALUES(%d);",
159 rid, rid, rid
160 );
161 db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
162 admin_log("Approved moderation of rid %d.", rid);
 
163 db_end_transaction(0);
164 }
165
166 /*
167 ** WEBPAGE: modreq
168
--- src/moderate.c
+++ src/moderate.c
@@ -147,21 +147,22 @@
147 }
148
149 /*
150 ** Approve an object held for moderation.
151 */
152 void moderation_approve(char class, int rid){
153 if( !moderation_pending(rid) ) return;
154 db_begin_transaction();
155 db_multi_exec(
156 "DELETE FROM private WHERE rid=%d;"
157 "INSERT OR IGNORE INTO unclustered VALUES(%d);"
158 "INSERT OR IGNORE INTO unsent VALUES(%d);",
159 rid, rid, rid
160 );
161 db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid);
162 admin_log("Approved moderation of rid %c-%d.", class, rid);
163 if( class!='a' ) search_doc_touch(class, rid, 0);
164 db_end_transaction(0);
165 }
166
167 /*
168 ** WEBPAGE: modreq
169
+1 -1
--- src/search.c
+++ src/search.c
@@ -1585,11 +1585,11 @@
15851585
** updated. If the document has already been indexed, then unindex it
15861586
** now while we still have access to the old content. Add the document
15871587
** to the queue of documents that need to be indexed or reindexed.
15881588
*/
15891589
void search_doc_touch(char cType, int rid, const char *zName){
1590
- if( search_index_exists() ){
1590
+ if( search_index_exists() && !content_is_private(rid) ){
15911591
char zType[2];
15921592
zType[0] = cType;
15931593
zType[1] = 0;
15941594
search_sql_setup(g.db);
15951595
db_multi_exec(
15961596
--- src/search.c
+++ src/search.c
@@ -1585,11 +1585,11 @@
1585 ** updated. If the document has already been indexed, then unindex it
1586 ** now while we still have access to the old content. Add the document
1587 ** to the queue of documents that need to be indexed or reindexed.
1588 */
1589 void search_doc_touch(char cType, int rid, const char *zName){
1590 if( search_index_exists() ){
1591 char zType[2];
1592 zType[0] = cType;
1593 zType[1] = 0;
1594 search_sql_setup(g.db);
1595 db_multi_exec(
1596
--- src/search.c
+++ src/search.c
@@ -1585,11 +1585,11 @@
1585 ** updated. If the document has already been indexed, then unindex it
1586 ** now while we still have access to the old content. Add the document
1587 ** to the queue of documents that need to be indexed or reindexed.
1588 */
1589 void search_doc_touch(char cType, int rid, const char *zName){
1590 if( search_index_exists() && !content_is_private(rid) ){
1591 char zType[2];
1592 zType[0] = cType;
1593 zType[1] = 0;
1594 search_sql_setup(g.db);
1595 db_multi_exec(
1596

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button