FIX: Circular references warning in TopicTrackingState.

This commit is contained in:
Guo Xiang Tan 2018-03-13 08:35:15 +08:00
parent ab2f3e43eb
commit d5c828213f
3 changed files with 8 additions and 6 deletions

View File

@ -246,7 +246,10 @@ SQL
sql sql
end end
def self.publish_private_message(topic, user_id: user_id, user_archive: false, post: nil, group_archive: false) def self.publish_private_message(topic, archive_user_id: archive_user_id,
post: nil,
group_archive: false)
return unless topic.private_message? return unless topic.private_message?
channels = {} channels = {}
@ -254,8 +257,8 @@ SQL
if post && allowed_user_ids.include?(post.user_id) if post && allowed_user_ids.include?(post.user_id)
channels["/private-messages/sent"] = [post.user_id] channels["/private-messages/sent"] = [post.user_id]
elsif user_archive elsif archive_user_id
user_ids = [user_id] user_ids = [archive_user_id]
[ [
"/private-messages/archive", "/private-messages/archive",

View File

@ -38,7 +38,7 @@ class UserArchivedMessage < ActiveRecord::Base
def self.publish_topic_tracking_state(topic, user_id) def self.publish_topic_tracking_state(topic, user_id)
TopicTrackingState.publish_private_message( TopicTrackingState.publish_private_message(
topic, user_id: user_id, user_archive: true topic, archive_user_id: user_id
) )
end end
end end

View File

@ -189,8 +189,7 @@ describe TopicTrackingState do
messages = MessageBus.track_publish do messages = MessageBus.track_publish do
TopicTrackingState.publish_private_message( TopicTrackingState.publish_private_message(
private_message_topic, private_message_topic,
user_id: private_message_post.user_id, archive_user_id: private_message_post.user_id,
user_archive: true
) )
end end