diff --git a/profiles/twitch/component.py b/profiles/twitch/component.py index b7cb256..51e4608 100644 --- a/profiles/twitch/component.py +++ b/profiles/twitch/component.py @@ -41,22 +41,20 @@ class ProfilesComponent(cmds.Component): Fetch or create the profile for the given user. """ userid = str(user.id) - async with self.bot.dbconn.connection() as conn: - self.bot.dbconn.conn = conn - async with conn.transaction(): - profile = await self.profiles.get_profile_twitch(userid) - if profile is None: - args = {} - try: - user = await user.user() - args['nickname'] = user.display_name - args['avatar'] = user.profile_image.url - except twitchio.HTTPException: - pass - profile = await UserProfile.create(**args) - await TwitchProfileLink.create(profileid=profile.profileid, userid=userid) - elif touch: - await profile.update(last_seen=utc_now()) + # TODO: Transaction + profile = await self.profiles.get_profile_twitch(userid) + if profile is None: + args = {} + try: + user = await user.user() + args['nickname'] = user.display_name + args['avatar'] = user.profile_image.url + except twitchio.HTTPException: + pass + profile = await UserProfile.create(**args) + await TwitchProfileLink.create(profileid=profile.profileid, userid=userid) + elif touch: + await profile.update(last_seen=utc_now()) return profile @@ -70,14 +68,12 @@ class ProfilesComponent(cmds.Component): Fetch or create the community for this channel. """ chanid = channel.id - async with self.bot.dbconn.connection() as conn: - self.bot.dbconn.conn = conn - async with conn.transaction(): - comm = await self.profiles.get_community_twitch(chanid) - if comm is None: - comm = await Community.create() - await TwitchCommunityLink.create(channelid=chanid, communityid=comm.communityid) - elif touch: - await comm.update(last_seen=utc_now()) + # TODO: Transaction + comm = await self.profiles.get_community_twitch(chanid) + if comm is None: + comm = await Community.create() + await TwitchCommunityLink.create(channelid=chanid, communityid=comm.communityid) + elif touch: + await comm.update(last_seen=utc_now()) return comm