devanooga / devanoobot

The bigger bot that might.
0 stars 3 forks source link

Channel purge #14

Closed agarzola closed 6 years ago

agarzola commented 6 years ago

This PR implements two standalone cron jobs and one new endpoint in the Express server. It also establishes a sqlite3 database, with an interface via knex.js.

Notify channels job

Finds all unarchived channels with no activity in the past 30 days and:

Purge channels job

Finds all records in the purge_queue table and:

Cancel channel purge endpoint

Purge notification messages are interactive. They have a Don’t Archive button which, when clicked, triggers a POST request to this endpoint, which finds any records with the relevant channel’s ID in the purge_queue table and deletes them. If successful, the message is updated to reflect the fact that the channel is no longer in the purge queue, and unpins it. If unsuccessful, it returns a 500 status, which leaves the message intact and results in an ephemeral error message that only the user who clicked on the button can see.

agarzola commented 6 years ago

Need to add migrations to the deployment script.

agarzola commented 6 years ago

Gotta get this through next hacknight, srsly.

Also, we need to look into running the pm2 config as a service so that service interruptions don’t require a manual restart.

brb3 commented 6 years ago

All looks good to me :+1:. I'm not a node expert by any stretch, but it looks like you are handling errors, bulding queries sanely, all that jazz. Merge that ish.