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

Added functionality to auto-wipe inactive records #91

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cskartikey
Copy link

@cskartikey cskartikey commented Apr 11, 2024

Integrates: Entries should be wiped from the confessions DB one week after the last reply from OP

Make sure to META_CHANNEL_ID and API_SECRET before merging

Feel free to request a review if you believe there are better names for new variables or if you have suggestions for improving the implementation logic.

Copy link

vercel bot commented Apr 11, 2024

Someone is attempting to deploy a commit to a Personal Account owned by @anirudhb on Vercel.

@anirudhb first needs to authorize it.

@cskartikey cskartikey marked this pull request as draft April 11, 2024 18:06
Copy link
Owner

@anirudhb anirudhb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +600 to +601
record.uid_salt = "empty"
record.uid_hash = "empty hash";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, using all zeros would be okay too

Suggested change
record.uid_salt = "empty"
record.uid_hash = "empty hash";
record.uid_salt = ""
// hashUser("", "")
record.uid_hash = "d72c87d0f077c7766f2985dfab30e8955c373a13a1e93d315203939f542ff86e73ee37c31f4c4b571f4719fa8e3589f12db8dcb57ea9f56764bb7d58f64cf705";

const now = new Date();
const weekAgo = now.setDate(now.getDate() - 7) / 1000;
const old_published_ts = record.published_ts;
if (!old_published_ts) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to check if the confession was rejected

record: Confession,
): Promise<boolean> {
const now = new Date();
const weekAgo = now.setDate(now.getDate() - 7) / 1000;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to compare with a constant (for example 7*24*60*60*1000)

const now = new Date();
const weekAgo = now.setDate(now.getDate() - 7) / 1000;
recordsFetched = await repository.find({
where: [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May also be a good idea to filter out confessions that already have an empty hash/salt set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants