From d77f2181229036fea453216c2a6d1334095835ed Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Mon, 10 Nov 2014 21:24:54 +1100
Subject: [PATCH] Don't try to publish messages on broken posts

---
 app/models/post.rb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/models/post.rb b/app/models/post.rb
index 8ce68da34d4..d67dc4cd2ef 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -93,12 +93,15 @@ class Post < ActiveRecord::Base
   end
 
   def publish_change_to_clients!(type)
+    # special failsafe for posts missing topics
+    # consistency checks should fix, but message
+    # is safe to skip
     MessageBus.publish("/topic/#{topic_id}", {
         id: id,
         post_number: post_number,
         updated_at: Time.now,
         type: type
-    }, group_ids: topic.secure_group_ids)
+    }, group_ids: topic.secure_group_ids) if topic
   end
 
   def trash!(trashed_by=nil)