Skip to content

Commit

Permalink
Fix notifications building from JSON
Browse files Browse the repository at this point in the history
Sometimes (like in welcome messages), notifications don't have a
'title' property, so we shouldn't assume there is one.

Bug: T139015
Change-Id: I83e480d04e8e09aa9bcb5edef4f56b47d150e199
(cherry picked from commit d387ab2)
  • Loading branch information
enterprisey authored and jayvdb committed Jul 2, 2016
1 parent 0af6751 commit 18a1574
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pywikibot/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def fromJSON(cls, site, data):
notif.category = data['category']
notif.timestamp = pywikibot.Timestamp.fromtimestampformat(data['timestamp']['mw'])

# TODO: use 'namespace-key' + 'text' ?
notif.page = pywikibot.Page(site, data['title']['full'])
if 'title' in data and 'full' in data['title']:
notif.page = pywikibot.Page(site, data['title']['full'])
else:
notif.page = None

if 'agent' in data and 'name' in data['agent']:
notif.agent = pywikibot.User(site, data['agent']['name'])
Expand Down

0 comments on commit 18a1574

Please sign in to comment.