Fix #5435 - Bad comment links cause server error
authorAndrew Browning <ayleph@thisshitistemp.com>
Wed, 2 Mar 2016 17:29:33 +0000 (12:29 -0500)
committerAndrew Browning <ayleph@thisshitistemp.com>
Wed, 2 Mar 2016 17:31:55 +0000 (12:31 -0500)
This patch addresses an issue where a server error is caused by
entering a non-existent comment ID in a media URL.

mediagoblin/notifications/__init__.py

index 9d2f2b7835e86b686d316b9378960f4f9ec4b4c1..d554de2d420aeb22f75e900ed785a871553ed919 100644 (file)
@@ -71,6 +71,11 @@ def mark_notification_seen(notification):
 
 def mark_comment_notification_seen(comment_id, user):
     comment = Comment.query.get(comment_id)
+
+    # If there is no comment, there is no notification
+    if comment == None:
+        return
+
     comment_gmr = GenericModelReference.query.filter_by(
         obj_pk=comment.id,
         model_type=comment.__tablename__