Rafał Pitoń 8 years ago
parent
commit
c9df05d4e0

+ 3 - 1
misago/threads/api/postingendpoint/emailnotification.py

@@ -30,7 +30,9 @@ class EmailNotificationMiddleware(PostingMiddleware):
             send_messages(notifications)
             send_messages(notifications)
 
 
     def notify_user_of_post(self, subscriber):
     def notify_user_of_post(self, subscriber):
-        return can_see_thread(subscriber, self.thread) and can_see_post(subscriber, self.post)
+        see_thread = can_see_thread(subscriber, self.thread)
+        see_post = can_see_post(subscriber, self.post)
+        return see_thread and see_post
 
 
     def build_mail(self, subscriber):
     def build_mail(self, subscriber):
         if subscriber.id == self.thread.starter_id:
         if subscriber.id == self.thread.starter_id:

+ 22 - 0
misago/threads/tests/test_threadview.py

@@ -531,3 +531,25 @@ class ThreadLikedPostsViewTests(ThreadViewTestCase):
         self.assertNotContains(response, '"is_liked": true')
         self.assertNotContains(response, '"is_liked": true')
         self.assertNotContains(response, '"is_liked": false')
         self.assertNotContains(response, '"is_liked": false')
         self.assertContains(response, '"is_liked": null')
         self.assertContains(response, '"is_liked": null')
+
+
+class ThreadAnonViewTests(ThreadViewTestCase):
+    def test_anonymous_user_view_no_showstoppers_display(self):
+        """kitchensink thread view has no showstoppers for anons"""
+        poll = testutils.post_poll(self.thread, self.user)
+        event = record_event(MockRequest(self.user), self.thread, 'closed')
+
+        hidden_event = record_event(MockRequest(self.user), self.thread, 'opened')
+        hide_post(self.user, hidden_event)
+
+        unapproved_post = testutils.reply_thread(self.thread, is_unapproved=True)
+        post = testutils.reply_thread(self.thread)
+
+        self.logout_user()
+
+        response = self.client.get(self.thread.get_absolute_url())
+        self.assertContains(response, poll.question)
+        self.assertContains(response, event.get_absolute_url())
+        self.assertContains(response, post.get_absolute_url())
+        self.assertNotContains(response, hidden_event.get_absolute_url())
+        self.assertNotContains(response, unapproved_post.get_absolute_url())