2023-08-16 16:29:58 -04:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
import { computed } from "@ember/object";
|
2024-11-19 05:57:40 -05:00
|
|
|
import { service } from "@ember/service";
|
2023-10-23 02:00:58 -04:00
|
|
|
import I18n from "discourse-i18n";
|
2023-08-16 16:29:58 -04:00
|
|
|
|
|
|
|
export default class extends Component {
|
|
|
|
@service currentUser;
|
|
|
|
@service siteSettings;
|
|
|
|
|
|
|
|
get composerModel() {
|
2023-08-17 00:43:14 -04:00
|
|
|
return this.args?.outletArgs?.composer;
|
2023-08-16 16:29:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
get renderChatWarning() {
|
|
|
|
return this.siteSettings.ai_bot_enable_chat_warning;
|
|
|
|
}
|
|
|
|
|
2023-10-23 02:00:58 -04:00
|
|
|
@computed("composerModel.targetRecipients", "composerModel.title")
|
|
|
|
get aiBotClasses() {
|
|
|
|
if (
|
|
|
|
this.composerModel?.title ===
|
|
|
|
I18n.t("discourse_ai.ai_bot.default_pm_prefix")
|
|
|
|
) {
|
|
|
|
return "ai-bot-chat";
|
|
|
|
} else {
|
|
|
|
return "ai-bot-pm";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-16 16:29:58 -04:00
|
|
|
@computed("composerModel.targetRecipients")
|
|
|
|
get isAiBotChat() {
|
2023-08-16 21:00:11 -04:00
|
|
|
if (
|
2023-08-17 00:43:14 -04:00
|
|
|
this.composerModel &&
|
2023-08-16 21:00:11 -04:00
|
|
|
this.composerModel.targetRecipients &&
|
|
|
|
this.currentUser.ai_enabled_chat_bots
|
|
|
|
) {
|
2024-01-19 06:51:26 -05:00
|
|
|
let recipients = this.composerModel.targetRecipients.split(",");
|
2023-08-16 16:29:58 -04:00
|
|
|
|
|
|
|
return this.currentUser.ai_enabled_chat_bots.any((bot) =>
|
2024-01-19 06:51:26 -05:00
|
|
|
recipients.any((username) => username === bot.username)
|
2023-08-16 16:29:58 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|