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

Post Deletion Timeline Implementation #61

Open
4 tasks
DanielChee opened this issue Feb 2, 2025 · 0 comments
Open
4 tasks

Post Deletion Timeline Implementation #61

DanielChee opened this issue Feb 2, 2025 · 0 comments

Comments

@DanielChee
Copy link
Collaborator

DanielChee commented Feb 2, 2025

Description

At the moment, we have the postDeletionTimeline field for all Users, which is meant to specify how long a post should remain on the FOCUS site before it is to be automatically deleted.

This is what postDeletionTimeline looks like in the User schema:

//  utils/consts.ts:
enum PostDeletionTimeline {
  OneMonth = '1 month',
  ThreeMonths = '3 months',
  SixMonths = '6 months',
  OneYear = '1 year',
  TwoYears = '2 years',
  FourYears = '4 years', };

//  utils/types/user.ts:
postDeletionTimeline: z.enum(Object.values(PostDeletionTimeline) as [PostDeletionTimeline,
...PostDeletionTimeline[]]).default(PostDeletionTimeline.FourYears)

And in the frontend User Settings & Preferences page:

Image

Goal

We want to implement the functionality for postDeletionTimeline. Depending on what duration the user selects, we want to implement a MongoDB property for all Post documents to have a time to live, or TTL, Index. Then, MongoDB will automatically deal with posts that reach the end of their life by deleting them from the database.

TTL Index

TTL Index Documentation

Retroactive expiration

If a user changes their postDeletionTimeline from a longer duration to a shorter duration (Like 4 years -> 1 month), we need to delete any existing posts that exceed this duration. If a user chooses an option that is less than the current option, provide a popup that warns the user that "Any posts that you have posted over [duration] ago will be deleted forever"

If they agree and you need to delete posts, go through all the posts that a user owns and delete it if currentTime - Post.date > postDeletionTimeline. Basically if any post is older than the newly selected postDeletionTimeline, delete it.

Acceptance Criteria

  • A post will expire [duration] seconds after it has been posted
  • postDeletionTimeline functionality works for (4 years / 2 years / 1 year / 6 months / 3 months / 1 month).
    • Turn these durations into seconds to be inputted into the expireAfterSeconds field in MongoDB.
  • If a user updates their postDeletionTimeline to be shorter than the current postDeletionTimeline, provide a warning
  • Posts can be deleted retroactively by iterating through a user's posts and calculating post age.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants