Fixed handling of poster size and language if user did not set these values

This commit is contained in:
lomion 2020-09-29 09:49:16 +02:00
parent 5069551064
commit 94baaf9296
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,6 @@
maubot: 0.1.0 maubot: 0.1.0
id: lomion.tmdb id: lomion.tmdb
version: 1.0.0 version: 1.0.1
license: AGPL 3.0 license: AGPL 3.0
modules: modules:
- tmdb - tmdb

View file

@ -45,7 +45,11 @@ class Database:
def get_language(self, user_id): def get_language(self, user_id):
rows = self.db.execute(select([self.language.c.language]) rows = self.db.execute(select([self.language.c.language])
.where(self.language.c.user_id == user_id)) .where(self.language.c.user_id == user_id))
return rows.fetchone()['language'] row = rows.fetchone()
if row:
return row['language']
else:
return None
def set_poster_size(self, user_id, size): def set_poster_size(self, user_id, size):
with self.db.begin() as tx: with self.db.begin() as tx:
@ -55,4 +59,8 @@ class Database:
def get_poster_size(self, user_id): def get_poster_size(self, user_id):
rows = self.db.execute(select([self.tmdb_poster_size.c.size]) rows = self.db.execute(select([self.tmdb_poster_size.c.size])
.where(self.tmdb_poster_size.c.user_id == user_id)) .where(self.tmdb_poster_size.c.user_id == user_id))
return rows.fetchone()['size'] row = rows.fetchone()
if row:
return row['size']
else:
return None