SocksTheWolf / AntiScamBot

A Discord bot that shares ban lists of scammers across multiple Discord servers
https://scamguard.app/
MIT License
6 stars 3 forks source link

Db refactor #39

Closed user4752 closed 1 year ago

user4752 commented 1 year ago

closes #7

An opinionated database refactor to convert current raw SQL queries to an ORM library (SQLAlchemy) in order for the data returned from the database to be agnostic to the database engine selected, and allow for clarity on which fields are referenced, i.e. object.named_value versus object[random_index].

Will also allow for easier (and automatic) future migrations of the database should the project needs grow, or the database engine of choice change, e.g. sqlite to mysql/mariadb or postgres.

Opinions chosen are:

Visualization of the new database schema: Screenshot 2023-10-14 225122

Examples of the new database objects: Screenshot 2023-10-14 225132 Screenshot 2023-10-14 225138

Todo:

Current Caveats:

SocksTheWolf commented 1 year ago

Just reading the opinions of the setup here, I'll look through the code either tonight or tomorrow.

While I agree with a lot of the direction here, I am not sure about the soft deletion practice (specifically around servers). Discord data policies require that if a bot is no longer in a server:

I couldn't find what is deemed timely, so this cleanup process could just be whenever the bot next does a reconcile operation, or have it on a timer (we can push this in outside of this pr).

user4752 commented 1 year ago

While I agree with a lot of the direction here, I am not sure about the soft deletion practice (specifically around servers). Discord data policies require that if a bot is no longer in a server:

  • Information about that server is no longer gathered (does not apply to us)
  • Any data stored about that server is removed in a timely manner

The soft deletion was meant more as a simplified audit log saying "oh we've interacted with server at least once before" / "we've unbanned this user once before", but it can easy be removed, or actually migrated to a proper audit log. Declaring it as a proper audit log may allow retention to better fall under the 'Applications stated functionality clause' (§5.b ¶2).

Either way, removal is trivial, and would remove one dependency if done so.

SocksTheWolf commented 1 year ago

Okay I've been super busy these last few days so I haven't had a chance to look over stuff. I will try to get some time in early next week at the latest.

I'll try to start the review today.

user4752 commented 1 year ago

Thank you very much for this, I apologize for taking so long to get to it. Had a couple unforeseen circumstances come up, so I was unable to review it until now.

Not a worry, I was aware of the craziness of last week and can only imagine the stress it caused.

Most of your comment replies are on my aforementioned todo list; this initial set of commits was to gauge interest, design and compatibility. Will be commenting directly back on the individual issues shortly.

user4752 commented 1 year ago

Was there a final opinion on the soft-delete, and/or an opinion on the reported history / audit log (ref #36)? The former to remove if need be, and the later to prep for implementation in the schema as it will directory dictate some of my replies to the review.

SocksTheWolf commented 1 year ago

Was there a final opinion on the soft-delete, and/or an opinion on the reported history / audit log (ref #36)? The former to remove if need be, and the later to prep for implementation in the schema as it will directory dictate some of my replies to the review.

Yes, I don't think it's something we should pursue.

user4752 commented 1 year ago

Closing pull request due to conflicts with v1.5.0 release. Will rebase and open new pull request soon.