MCPcopy Create free account
hub / github.com/error311/FileRise / loadPublicAiConfig

Function loadPublicAiConfig

public/js/sharedFolderView.js:356–387  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

354 }
355
356 async function loadPublicAiConfig() {
357 const siteCfg = await loadPublicSiteConfig();
358 if (!siteCfg || !siteCfg.pro || siteCfg.pro.active !== true) {
359 return { enabled: false };
360 }
361 if (publicAiConfigPromise) return publicAiConfigPromise;
362 publicAiConfigPromise = fetch(withBasePath('/api/pro/ai/config/public.php'), {
363 method: 'GET',
364 credentials: 'same-origin',
365 headers: {
366 Accept: 'application/json'
367 }
368 })
369 .then(async function (res) {
370 const raw = await res.text();
371 let data = {};
372 try {
373 data = JSON.parse(raw || '{}');
374 } catch (e) {
375 data = {};
376 }
377 const settings = data && data.settings && typeof data.settings === 'object' ? data.settings : {};
378 const providers = Array.isArray(settings.providers) ? settings.providers : [];
379 return {
380 enabled: !!settings.chatEnabled && providers.length > 0
381 };
382 })
383 .catch(function () {
384 return { enabled: false };
385 });
386 return publicAiConfigPromise;
387 }
388
389 function createShareCopilotCard() {
390 const host = document.createElement('section');

Callers 1

mountShareCopilotFunction · 0.70

Calls 2

loadPublicSiteConfigFunction · 0.85
withBasePathFunction · 0.70

Tested by

no test coverage detected