2024-09-13 14:59:30 -04:00
|
|
|
export function showComposerAiHelper(
|
|
|
|
composerModel,
|
|
|
|
siteSettings,
|
|
|
|
currentUser,
|
|
|
|
featureType
|
|
|
|
) {
|
|
|
|
const enableHelper = _helperEnabled(siteSettings);
|
|
|
|
const enableAssistant = currentUser.can_use_assistant;
|
|
|
|
const canShowInPM = siteSettings.ai_helper_allowed_in_pm;
|
2024-02-01 17:58:04 -05:00
|
|
|
const enableFeature =
|
2024-09-13 14:59:30 -04:00
|
|
|
siteSettings.ai_helper_enabled_features.includes(featureType);
|
2023-09-13 17:18:48 -04:00
|
|
|
|
2024-09-13 14:59:30 -04:00
|
|
|
if (composerModel?.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) {
|
2024-08-12 18:40:23 -04:00
|
|
|
return siteSettings.discourse_ai_enabled && siteSettings.ai_helper_enabled;
|
2023-10-23 10:41:36 -04:00
|
|
|
}
|