mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 18:06:08 -05:00
Begin work on a data request API (#4045)
[Core] Data Deletion And Disclosure APIs - Adds a Data Deletion API - Deletion comes in a few forms based on who is requesting - Deletion must be handled by 3rd party - Adds a Data Collection Disclosure Command - Provides a dynamically generated statement from 3rd party extensions - Modifies the always available commands to be cog compatible - Also prevents them from being unloaded accidentally
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Mapping
|
||||
from typing import Literal, Mapping
|
||||
|
||||
from redbot.core import commands
|
||||
from ..abc import MixinMeta
|
||||
@@ -19,3 +20,37 @@ class RedEvents(MixinMeta, metaclass=CompositeMetaClass):
|
||||
self.api_interface.spotify_api.update_token(api_tokens)
|
||||
elif service_name == "audiodb":
|
||||
self.api_interface.global_cache_api.update_token(api_tokens)
|
||||
|
||||
async def red_delete_data_for_user(
|
||||
self,
|
||||
*,
|
||||
requester: Literal["discord_deleted_user", "owner", "user", "user_strict"],
|
||||
user_id: int,
|
||||
):
|
||||
|
||||
await self.cog_ready_event.wait()
|
||||
|
||||
if requester in ("discord_deleted_user", "owner"):
|
||||
await self.playlist_api.handle_playlist_user_id_deletion(user_id)
|
||||
|
||||
all_equalizers = await self.config.custom("EQUALIZER").all()
|
||||
|
||||
collected_for_removal = []
|
||||
|
||||
c = 0
|
||||
for guild_id, guild_equalizers in all_equalizers.items():
|
||||
c += 1
|
||||
if not c % 100:
|
||||
await asyncio.sleep(0)
|
||||
|
||||
for preset_name, preset in guild_equalizers.get("eq_presets", {}).items():
|
||||
c += 1
|
||||
if not c % 100:
|
||||
await asyncio.sleep(0)
|
||||
|
||||
if preset.get("author", 0) == user_id:
|
||||
collected_for_removal.append((guild_id, preset_name))
|
||||
|
||||
async with self.config.custom("EQUALIZER").all() as all_eqs:
|
||||
for guild_id, preset_name in collected_for_removal:
|
||||
all_eqs[str(guild_id)]["eq_presets"][preset_name]["author"] = 0xDE1
|
||||
|
||||
Reference in New Issue
Block a user