FIX: Restore join to user_emails for backwards compatibility

FIX: Restore join to user_emails for backwards compatibility

Followup to a8310b4b

diff --git a/plugin.rb b/plugin.rb
index f7d8c7d..d1547ec 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -141,6 +141,10 @@ after_initialize do
         )", topics.map(&:id))
           .select(lookup_columns)
 
+        if !defined?(UserLookup) # Remove after Discourse 2.6.0
+          users = users.joins('join user_emails on user_emails.user_id = users.id AND user_emails.primary')
+        end
+
         map = {}
         users.each { |u| map[u.id] = u }
 

GitHub sha: e31454e0

1 Like