JDsProjects / JDBot

the official JDBot rewrite :D
MIT License
19 stars 35 forks source link

Adding Invalidation Config #122

Open JDJGInc opened 1 year ago

JDJGInc commented 1 year ago

Opt in:

  1. adds the option to be able to add in
CREATE TABLE invalidation_config (
    entity_id bigint NOT NULL,
    entity_type smallint NOT NULL,
    PRIMARY KEY (entity_id, entity_type)
);

types:

global - for you everywhere (a.k.a the user who optted in) guild -> for that guild(guild owner only) and then for that channel if you have proper permissions (invalidation config a.k.a token invalidation)

JDJGInc commented 1 year ago

https://github.com/JDsProjects/JDBot/commit/0bf964b9316a92c9e280493d7f42f023f148e0b4

brings up the schema here.

JDJGInc commented 1 year ago

https://github.com/JDsProjects/JDBot/commit/93985eb04289b0e39611d3f13a56703c879b6fe8

Enum made.

JDJGInc commented 1 year ago

everywhere -> user id guild -> guild id dm -> the user's dm channel id, Well user id works too I guess? channel -> channel id

JDJGInc commented 1 year ago

Note, it's everywhere as global in python is already used.

JDJGInc commented 1 year ago

https://github.com/JDsProjects/JDBot/blob/7ab824c4f3075b1ca443081c546fbfa753190db3/utils/views.py#L1673

view for the invalidation config selector.

JDJGInc commented 11 months ago

an opt out mood for those who are global will be made too, so another table will be made.

JDJGInc commented 11 months ago
CREATE TABLE invalidation_out (
    entity_id bigint NOT NULL,
    entity_type smallint NOT NULL,
    PRIMARY KEY (entity_id, entity_type)
);

All enum values are valid.

i thought everywhere and dm could be ignored but that makes no sense.

JDJGInc commented 8 months ago

Instead of TokenInvalidatorSettings, it may be better as slash.

JDJGInc commented 8 months ago

https://github.com/JDsProjects/JDBot/commit/d4fd43fdcccc79b898918390a45b22cbc75a84e3

JDJGInc commented 7 months ago

Bard's weird explanation that someone tried to give me but was somewhat helpful:

## Chat Summary (Bard and User):

**Topic:** Creating a custom cache for DPY with invalidation logic

**Key Points:**

- User needs to cache data from two tables (`invalidation_config` and `invalidation_out`) efficiently, prioritizing opt-out data over configurations.
- Caching uses `@functools.lru_cache` and custom methods for `InvalidateType` enums.
- User wants:
    - Object and helper methods for DPY.
    - Opt-out data always considered with higher priority.
    - Users can still manually invalidate tokens even when opted out.

**Solutions:**

- Provided `InvalidationCache` object with helper methods like `is_invalidated` and `is_token_invalidated`.
- Updated `is_invalidated` to prioritize opt-out data.
- Suggested adding `invalidate_token` method for manual invalidation.
- Advised on database interactions, error handling, and testing.

**Additional points:**

- User can export chat using various methods (copy-paste, browser tools, extensions).
- Chat summary provided for easy reference.

I hope this concise summary is helpful for you!
JDJGInc commented 7 months ago

As in google bard.

JDJGInc commented 6 months ago

https://github.com/JDsProjects/JDBot/commit/e1ed16246f5b28fffbf1478e0371f24634c41c09

JDJGInc commented 6 months ago

HMMM