2023-08-16 16:29:58 -04:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
import { inject as service } from "@ember/service";
|
|
|
|
import { computed } from "@ember/object";
|
|
|
|
|
|
|
|
export default class extends Component {
|
|
|
|
static shouldRender() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
|
) {
|
2023-08-16 16:29:58 -04:00
|
|
|
let reciepients = this.composerModel.targetRecipients.split(",");
|
|
|
|
|
|
|
|
return this.currentUser.ai_enabled_chat_bots.any((bot) =>
|
|
|
|
reciepients.any((username) => username === bot.username)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|