aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/api/bot
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-05-19 20:26:14 +0100
committerGravatar Gareth Coles <[email protected]>2018-05-19 20:26:14 +0100
commitb0d5bb41003d38b42ed1753b54366bbe965d5e76 (patch)
tree6ed3a422815ccca08ac6350d0c0e8bf8d4a9b269 /pysite/views/api/bot
parentUpdate nav/privacy policy (diff)
GDPR compliance for jammer profiles
Diffstat (limited to 'pysite/views/api/bot')
-rw-r--r--pysite/views/api/bot/user.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pysite/views/api/bot/user.py b/pysite/views/api/bot/user.py
index 58963682..cd66f3e8 100644
--- a/pysite/views/api/bot/user.py
+++ b/pysite/views/api/bot/user.py
@@ -32,6 +32,7 @@ class UserView(APIView, DBMixin):
name = "api.bot.user"
table_name = "users"
oauth_table_name = "oauth_data"
+ participants_table = "code_jam_participants"
@api_key
@api_params(schema=SCHEMA, validation_type=ValidationTypes.json)
@@ -40,6 +41,8 @@ class UserView(APIView, DBMixin):
deletions = 0
oauth_deletions = 0
+ profile_deletions = 0
+
user_ids = [user["user_id"] for user in data]
all_users = self.db.run(self.db.query(self.table_name), coerce=list)
@@ -54,7 +57,9 @@ class UserView(APIView, DBMixin):
for item in all_oauth_data:
if item["snowflake"] not in user_ids:
self.db.delete(self.oauth_table_name, item["id"], durability="soft")
+ self.db.delete(self.participants_table, item["id"], durability="soft")
oauth_deletions += 1
+ profile_deletions += 1
del user_ids
@@ -68,6 +73,7 @@ class UserView(APIView, DBMixin):
changes["deleted"] = deletions
changes["deleted_oauth"] = oauth_deletions
+ changes["deleted_jam_profiles"] = profile_deletions
return jsonify(changes) # pragma: no cover
@@ -98,6 +104,13 @@ class UserView(APIView, DBMixin):
.delete()
).get("deleted", 0)
+ profile_deletions = self.db.run(
+ self.db.query(self.participants_table)
+ .get_all(*user_ids)
+ .delete()
+ )
+
changes["deleted_oauth"] = oauth_deletions
+ changes["deleted_jam_profiles"] = profile_deletions
return jsonify(changes) # pragma: no cover