Compare commits
3 Commits
4653689e5e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c9b6ce8f60 | |||
| 0363dc2bcd | |||
| ce46bd49fe |
@@ -41,7 +41,7 @@ CREATE UNIQUE INDEX profiles_twitch_userid ON profiles_twitch (userid);
|
|||||||
|
|
||||||
CREATE TABLE communities(
|
CREATE TABLE communities(
|
||||||
communityid INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
communityid INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||||
migrated INTEGER REFERENCES user_profiles (profileid) ON DELETE CASCADE ON UPDATE CASCADE,
|
migrated INTEGER REFERENCES communities (communityid) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
last_seen TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
last_seen TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||||
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ class ProfilesComponent(cmds.Component):
|
|||||||
Fetch or create the profile for the given user.
|
Fetch or create the profile for the given user.
|
||||||
"""
|
"""
|
||||||
userid = str(user.id)
|
userid = str(user.id)
|
||||||
async with self.bot.dbconn.connection() as conn:
|
# TODO: Transaction
|
||||||
self.bot.dbconn.conn = conn
|
|
||||||
async with conn.transaction():
|
|
||||||
profile = await self.profiles.get_profile_twitch(userid)
|
profile = await self.profiles.get_profile_twitch(userid)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
args = {}
|
args = {}
|
||||||
@@ -53,6 +51,8 @@ class ProfilesComponent(cmds.Component):
|
|||||||
args['avatar'] = user.profile_image.url
|
args['avatar'] = user.profile_image.url
|
||||||
except twitchio.HTTPException:
|
except twitchio.HTTPException:
|
||||||
pass
|
pass
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
profile = await UserProfile.create(**args)
|
profile = await UserProfile.create(**args)
|
||||||
await TwitchProfileLink.create(profileid=profile.profileid, userid=userid)
|
await TwitchProfileLink.create(profileid=profile.profileid, userid=userid)
|
||||||
elif touch:
|
elif touch:
|
||||||
@@ -70,9 +70,7 @@ class ProfilesComponent(cmds.Component):
|
|||||||
Fetch or create the community for this channel.
|
Fetch or create the community for this channel.
|
||||||
"""
|
"""
|
||||||
chanid = channel.id
|
chanid = channel.id
|
||||||
async with self.bot.dbconn.connection() as conn:
|
# TODO: Transaction
|
||||||
self.bot.dbconn.conn = conn
|
|
||||||
async with conn.transaction():
|
|
||||||
comm = await self.profiles.get_community_twitch(chanid)
|
comm = await self.profiles.get_community_twitch(chanid)
|
||||||
if comm is None:
|
if comm is None:
|
||||||
comm = await Community.create()
|
comm = await Community.create()
|
||||||
|
|||||||
Reference in New Issue
Block a user