Hi,
I’m working on a plugin that filters all topics based on where the topic was posted from and what group the user viewing the topic is in. The use case here is having a support team in different countries handling questions coming out of their own locations.
I’m a newbie discourse plugin creator still learning how to do this. The topic location will be handled by the locations plugin here Locations Plugin
and I will add the users that need to have this filtered view to a group named something like NA_queue or EU_queue.
the plugin will check if the user is logged in and if the primary group is set. if it is, it will filter all topics to match the queue that the current user is a part of.
im thinking this might be done with something similar to the following code:
after_initialize do
require_dependency ‘topic_query’
# if logged in and with primary group set
# need to get user's primary group
# need to get topic location
TopicQuery.add_custom_filter(:location) do |results, topic_query|
filter = "SOME SQL QUERY HERE"
results = results.joins("{filter}")
results
end
Is this a good approach to my problem?
Also, does anyone have any suggestions on what the SQL would be or how to get those two commented pieces of information?