2024-02-01 17:58:04 -05:00
|
|
|
export function showComposerAIHelper(outletArgs, helper, featureType) {
|
2023-10-23 10:41:36 -04:00
|
|
|
const enableHelper = _helperEnabled(helper.siteSettings);
|
2024-02-18 21:26:24 -05:00
|
|
|
const enableAssistant = helper.currentUser.can_use_assistant;
|
2023-09-13 17:18:48 -04:00
|
|
|
const canShowInPM = helper.siteSettings.ai_helper_allowed_in_pm;
|
2024-02-01 17:58:04 -05:00
|
|
|
const enableFeature =
|
|
|
|
helper.siteSettings.ai_helper_enabled_features.includes(featureType);
|
2023-09-13 17:18:48 -04:00
|
|
|
|
|
|
|
if (outletArgs?.composer?.privateMessage) {
|
2024-02-01 17:58:04 -05:00
|
|
|
return enableHelper && enableAssistant && canShowInPM && enableFeature;
|
2023-09-13 17:18:48 -04:00
|
|
|
}
|
|
|
|
|
2024-02-01 17:58:04 -05:00
|
|
|
return enableHelper && enableAssistant && enableFeature;
|
2023-10-23 10:41:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function showPostAIHelper(outletArgs, helper) {
|
|
|
|
return (
|
|
|
|
_helperEnabled(helper.siteSettings) &&
|
2024-03-27 21:24:00 -04:00
|
|
|
helper.currentUser?.can_use_assistant_in_post
|
2023-10-23 10:41:36 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _helperEnabled(siteSettings) {
|
|
|
|
return (
|
|
|
|
siteSettings.discourse_ai_enabled && siteSettings.composer_ai_helper_enabled
|
|
|
|
);
|
|
|
|
}
|