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:
Michael H
2020-08-03 09:09:07 -04:00
committed by GitHub
parent bb1a256295
commit c0b1e50a5f
38 changed files with 1761 additions and 222 deletions

View File

@@ -3,7 +3,7 @@ import logging
import re
from abc import ABC
from collections import defaultdict
from typing import List, Tuple
from typing import List, Tuple, Literal
import discord
from redbot.core.utils import AsyncIter
@@ -83,6 +83,34 @@ class Mod(
self._ready = asyncio.Event()
async def red_delete_data_for_user(
self,
*,
requester: Literal["discord_deleted_user", "owner", "user", "user_strict"],
user_id: int,
):
if requester != "discord_deleted_user":
return
all_members = await self.config.all_members()
async for guild_id, guild_data in AsyncIter(all_members.items(), steps=100):
if user_id in guild_data:
await self.config.member_from_ids(guild_id, user_id).clear()
await self.config.user_from_id(user_id).clear()
guild_data = await self.config.all_guilds()
async for guild_id, guild_data in AsyncIter(guild_data.items(), steps=100):
if user_id in guild_data["current_tempbans"]:
async with self.config.guild_from_id(guild_id).current_tempbans() as tbs:
try:
tbs.remove(user_id)
except ValueError:
pass
# possible with a context switch between here and getting all guilds
async def initialize(self):
await self._maybe_update_config()
self._ready.set()