DEV: Fix `MessageBus::InvalidMessageTarget` error after upgrading mb.

DEV: Fix MessageBus::InvalidMessageTarget error after upgrading mb.

Follow-up to c2f2b57a9bbd9fdef74d1bde7a71de1abbcc08c5

diff --git a/app/models/category.rb b/app/models/category.rb
index 7c9a0ba..7c2a8ea 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -368,8 +368,22 @@ class Category < ActiveRecord::Base
   end
 
   def publish_category
-    group_ids = self.groups.pluck(:id) if self.read_restricted
-    MessageBus.publish('/categories', { categories: ActiveModel::ArraySerializer.new([self]).as_json }, group_ids: group_ids)
+    if self.read_restricted
+      group_ids = self.groups.pluck(:id)
+
+      if group_ids.present?
+        MessageBus.publish(
+          '/categories',
+          { categories: ActiveModel::ArraySerializer.new([self]).as_json },
+          group_ids: group_ids
+        )
+      end
+    else
+      MessageBus.publish(
+        '/categories',
+        { categories: ActiveModel::ArraySerializer.new([self]).as_json }
+      )
+    end
   end
 
   def remove_site_settings
diff --git a/app/models/post.rb b/app/models/post.rb
index c386ae1..0ad5e77 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -218,7 +218,9 @@ class Post < ActiveRecord::Base
         .pluck(:id)
     end
 
-    MessageBus.publish(channel, message, opts)
+    if opts[:user_ids] != [] && opts[:group_ids] != []
+      MessageBus.publish(channel, message, opts)
+    end
   end
 
   def trash!(trashed_by = nil)

GitHub sha: f7438fc6