From 47a0284e81a4fda636ce83f1fd48bd8974ad60c0 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Thu, 3 Jun 2021 20:08:03 -0400 Subject: [PATCH] Safety null checks for avatars --- matrix_puppeteer_line/db/stranger.py | 2 +- puppet/src/contentscript.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix_puppeteer_line/db/stranger.py b/matrix_puppeteer_line/db/stranger.py index 72e9e06..5de8a2e 100644 --- a/matrix_puppeteer_line/db/stranger.py +++ b/matrix_puppeteer_line/db/stranger.py @@ -61,7 +61,7 @@ class Stranger: async def get_by_profile(cls, info: 'Participant') -> Optional['Stranger']: q = ("SELECT fake_mid, name, avatar_path, available " "FROM stranger WHERE name=$1 AND avatar_path=$2") - row = await cls.db.fetchrow(q, info.name, info.avatar.path) + row = await cls.db.fetchrow(q, info.name, info.avatar.path if info.avatar else "") if not row: return None return cls(**row) diff --git a/puppet/src/contentscript.js b/puppet/src/contentscript.js index e6bd6e9..b73a34a 100644 --- a/puppet/src/contentscript.js +++ b/puppet/src/contentscript.js @@ -248,7 +248,7 @@ class MautrixController { .find(e => e.innerText == sender.name) if (participantNameElement) { imgElement = participantNameElement.previousElementSibling.firstElementChild - sender.id = imgElement.parentElement.parentElement.getAttribute("data-mid") + sender.id = imgElement?.parentElement.parentElement.getAttribute("data-mid") } } else { imgElement = element.querySelector(".mdRGT07Img > img")