From bbd5452b8d2678e54568f4e305266b33689afb0f Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Wed, 6 May 2015 13:25:23 +1000
Subject: [PATCH] Do not alert if we have no topic (eg topic deleted)

---
 app/jobs/regular/post_alert.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/jobs/regular/post_alert.rb b/app/jobs/regular/post_alert.rb
index 6d319b75a..d17ba0ca9 100644
--- a/app/jobs/regular/post_alert.rb
+++ b/app/jobs/regular/post_alert.rb
@@ -4,7 +4,8 @@ module Jobs
     def execute(args)
       # maybe it was removed by the time we are making the post
       if post = Post.find_by(id: args[:post_id])
-        PostAlerter.post_created(post)
+        # maybe the topic was deleted, so skip in that case as well
+        PostAlerter.post_created(post) if post.topic
       end
     end