DEV: Change to use UserLookup for core change (#77)

DEV: Change to use UserLookup for core change (#77)

See https://github.com/discourse/discourse/pull/10253

diff --git a/app/controllers/discourse_assign/assign_controller.rb b/app/controllers/discourse_assign/assign_controller.rb
index d9bf28d..3b90bf7 100644
--- a/app/controllers/discourse_assign/assign_controller.rb
+++ b/app/controllers/discourse_assign/assign_controller.rb
@@ -96,10 +96,13 @@ module DiscourseAssign
 
       Topic.preload_custom_fields(topics, TopicList.preloaded_custom_fields)
 
+      # TODO Drop AvatarLookup after Discourse 2.6.0 release
+      lookup_columns = defined?(UserLookup) ? UserLookup.lookup_columns : AvatarLookup.lookup_columns
+
       users = User
         .where("users.id IN (SELECT value::int FROM topic_custom_fields WHERE name = 'assigned_to_id' AND topic_id IN (?))", topics.map(&:id))
         .joins('join user_emails on user_emails.user_id = users.id AND user_emails.primary')
-        .select(AvatarLookup.lookup_columns)
+        .select(lookup_columns)
         .to_a
 
       # TODO Drop after Discourse 2.6.0 release
diff --git a/plugin.rb b/plugin.rb
index 738f849..e95850a 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -130,14 +130,16 @@ after_initialize do
       can_assign = topic_list.current_user && topic_list.current_user.can_assign?
       allowed_access = SiteSetting.assigns_public || can_assign
 
+      # TODO Drop AvatarLookup after Discourse 2.6.0 release
+      lookup_columns = defined?(UserLookup) ? UserLookup.lookup_columns : AvatarLookup.lookup_columns
+
       if allowed_access && topics.length > 0
         users = User.where("users.id in (
               SELECT value::int
               FROM topic_custom_fields
               WHERE name = 'assigned_to_id' AND topic_id IN (?)
         )", topics.map(&:id))
-          .joins('join user_emails on user_emails.user_id = users.id AND user_emails.primary')
-          .select(AvatarLookup.lookup_columns)
+          .select(lookup_columns)
 
         map = {}
         users.each { |u| map[u.id] = u }

GitHub sha: a8310b4b

This commit appears in #77 which was approved by ZogStriP. It was merged by davidtaylorhq.