added support for auto sage in index

main
fuzzykitten 2025-02-25 17:11:36 -05:00
parent d93f2e1574
commit 053b709ff0
1 changed files with 20 additions and 2 deletions

View File

@ -288,9 +288,27 @@ function bot_me($db, $settings)
}
// If the post is a reply, put the original post on top.
function bump_message($db, $org_id, $sub)
function bump_message($db, $org_id, $sub, $settings)
{
if ( $settings['auto_sage'] > 0 ) {
$statement = $db->prepare("SELECT global_id
FROM threads
WHERE org_id = '$org_id'
AND sub = '$sub'");
$result = $statement->execute();
$counter = 0;
while ($row = $result->fetchArray(SQLITE3_NUM)) {
$counter++;
}
if ( $counter > $settings['auto_sage'] ) {
return;
}
}
$statement = $db->prepare("SELECT text, global_id, text_id
FROM threads
WHERE post_id = '$org_id'
@ -1769,7 +1787,7 @@ function make_post($db, $sub, $settings, $text, $org_id)
if ( ($org_id != $post_id) &&
($settings['enable_bumping'] == TRUE) &&
(!isset($_POST['sage'])) ){
bump_message($db, $org_id, $sub);
bump_message($db, $org_id, $sub, $settings);
}
return $post_id;