Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting posts to rewind post counter #8

Open
kaguy4 opened this issue Jan 8, 2023 · 5 comments
Open

Deleting posts to rewind post counter #8

kaguy4 opened this issue Jan 8, 2023 · 5 comments
Labels
enhancement For stuff that needs to be improved

Comments

@kaguy4
Copy link
Member

kaguy4 commented Jan 8, 2023

Currently, each post increase the post counter, even if they are deleted and no posts are made after that

To explain with an example, if post no. 10 is registered but deleted before a post no.11 is made, the next post wouldn't replace post no.10 (as I would like it to) but continue from post no. 11. This wasn't always the case with Kokonotsuba

It would be better if it was rewinding the counter back when posts are deleted without any new is made. Heyuri especially has a severe issue of spammers who try to steal GETs, we could save them if we could count back post numbers too.

@kaguy4 kaguy4 added the enhancement For stuff that needs to be improved label Jan 8, 2023
@crazy4cars69
Copy link

This should be optional

@kinoko87
Copy link
Collaborator

Wouldn't this be not-to-difficult to implement?

If I were to implement it, it compromise of:

  1. Initiating all the data & stuff for a new post
  2. Check if the previous post exists, like if the new post is of ID 300, check if a post with ID 299 exists
  3. If the previous post does not exist, assign the soon-2-be new post to the previous ID, if not - continue

In the case that multiple posts were deleted, you could probably implement this recursively

fn fixPostID(postID) {
   num = postID; 
   if (!postExists(postID - 1)) {
       fixPostID(--postID);
   }
   return;
}

@kinoko87
Copy link
Collaborator

kinoko87 commented Jan 20, 2023

Would this be an efficient implementation?
Since I'm not really well-versed in how the code of Kokonotsuba works I can't make it accurate to the codebase, so I haven't made it a PR - plus I'll be able to probably setup Kokonotsuba after tommorow, as I'll be back home from vacation then.

<?php
function fixPostID($id) {
    $previousExists = query("EXISTS (SELECT * FROM posts WHERE id = ($id - 1))");
    if (!$previousExists) {
        return fixPostID(--$id);
    }

    return $id;
}
?>

@ghost
Copy link

ghost commented Jan 26, 2023

I just realized that it looks like the mod_rss.tmp file stores the post number for the next post. Perhaps on each delete we can decrement that number? What do y'all think about that idea? I may give it a try this weekend and see if it works depending on how much free time I have

@kaguy4
Copy link
Member Author

kaguy4 commented Jan 26, 2023

I don't know much, but would that work if a new post is made before the deletion?

This shouldn't happen:

  1. spambot makes post no 42
  2. user makes post no 43
  3. moderator deletes post no 42
  4. user makes post no 43 (wormhole is summoned)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For stuff that needs to be improved
Projects
None yet
Development

No branches or pull requests

3 participants