generated from HoloTech/twitch-bot-template
Temporary fix for transaction issues.
This commit is contained in:
@@ -178,17 +178,15 @@ class Bot(commands.Bot):
|
|||||||
|
|
||||||
# Save the token and scopes to data
|
# Save the token and scopes to data
|
||||||
# Wrap this in a transaction so if it fails halfway we rollback correctly
|
# Wrap this in a transaction so if it fails halfway we rollback correctly
|
||||||
async with self.dbconn.connection() as conn:
|
# TODO
|
||||||
self.dbconn.conn = conn
|
row = await UserAuth.fetch_or_create(userid, token=token, refresh_token=refresh)
|
||||||
async with conn.transaction():
|
if row.token != token or row.refresh_token != refresh:
|
||||||
row = await UserAuth.fetch_or_create(userid, token=token, refresh_token=refresh)
|
await row.update(token=token, refresh_token=refresh)
|
||||||
if row.token != token or row.refresh_token != refresh:
|
await self.data.user_auth_scopes.delete_where(userid=userid)
|
||||||
await row.update(token=token, refresh_token=refresh)
|
await self.data.user_auth_scopes.insert_many(
|
||||||
await self.data.user_auth_scopes.delete_where(userid=userid)
|
('userid', 'scope'),
|
||||||
await self.data.user_auth_scopes.insert_many(
|
*((userid, scope) for scope in new_scopes)
|
||||||
('userid', 'scope'),
|
)
|
||||||
*((userid, scope) for scope in new_scopes)
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.info("Updated auth token for user '%s' with scopes: %s", resp.user_id, ', '.join(new_scopes))
|
logger.info("Updated auth token for user '%s' with scopes: %s", resp.user_id, ', '.join(new_scopes))
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
Submodule src/modules/profiles updated: 4653689e5e...ce46bd49fe
Submodule src/modules/subathon updated: 18f57d1800...2c8bc4ae24
Reference in New Issue
Block a user