mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: allow re-scoping chat user search via a plugin (#26361)
This enables the following in Discourse AI
```
plugin.register_modifier(:chat_allowed_bot_user_ids) do |user_ids, guardian|
if guardian.user
mentionables = AiPersona.mentionables(user: guardian.user)
allowed_bot_ids = mentionables.map { |mentionable| mentionable[:user_id] }
user_ids.concat(allowed_bot_ids)
end
user_ids
end
```
some bots that are id < 0 need to be discoverable in search otherwise people can not talk to them.
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
@@ -1781,6 +1781,17 @@ RSpec.describe User do
|
||||
end
|
||||
end
|
||||
|
||||
describe "real users" do
|
||||
it "should find system user if you allow it" do
|
||||
ids =
|
||||
User
|
||||
.real(allowed_bot_user_ids: [Discourse.system_user.id])
|
||||
.where(id: Discourse.system_user.id)
|
||||
.pluck(:id)
|
||||
expect(ids).to eq([Discourse.system_user.id])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#purge_unactivated" do
|
||||
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
|
||||
fab!(:unactivated) { Fabricate(:user, active: false) }
|
||||
|
||||
Reference in New Issue
Block a user