Merge pull request #20 from Codium-ai/bugfix/crash_protection

Protect against no notifications received
This commit is contained in:
Ori Kotek
2023-07-06 20:16:42 +03:00
committed by GitHub

View File

@ -58,8 +58,6 @@ async def polling_loop():
if not notifications: if not notifications:
continue continue
for notification in notifications: for notification in notifications:
if 'id' in notification and notification['id'] in handled_ids:
continue
handled_ids.add(notification['id']) handled_ids.add(notification['id'])
if 'reason' in notification and notification['reason'] == 'mention': if 'reason' in notification and notification['reason'] == 'mention':
if 'subject' in notification and notification['subject']['type'] == 'PullRequest': if 'subject' in notification and notification['subject']['type'] == 'PullRequest':
@ -68,6 +66,11 @@ async def polling_loop():
async with session.get(latest_comment, headers=headers) as comment_response: async with session.get(latest_comment, headers=headers) as comment_response:
if comment_response.status == 200: if comment_response.status == 200:
comment = await comment_response.json() comment = await comment_response.json()
if 'id' in comment:
if comment['id'] in handled_ids:
continue
else:
handled_ids.add(comment['id'])
if 'user' in comment and 'login' in comment['user']: if 'user' in comment and 'login' in comment['user']:
if comment['user']['login'] == user_id: if comment['user']['login'] == user_id:
continue continue