403Webshell
Server IP : 66.29.153.156  /  Your IP : 216.73.217.22
Web Server : LiteSpeed
System : Linux premium322.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User : lastyfjz ( 1521)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/lastyfjz/./unicitys.com/wp-content/plugins/extendify/src/AutoLaunch/fetchers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/lastyfjz/./unicitys.com/wp-content/plugins/extendify/src/AutoLaunch/fetchers/get-profile.js
import { getProfileShape } from '@auto-launch/fetchers/shape';
import { fetchWithTimeout, setStatus } from '@auto-launch/functions/helpers';
import { updateOption } from '@auto-launch/functions/wp';
import { overrideWithUrlParams } from '@auto-launch/state/url-params';
import { AI_HOST } from '@constants';
import { reqDataBasics } from '@shared/lib/data';
import { __ } from '@wordpress/i18n';
import { z } from 'zod';

const localShape = z.object({
	siteProfile: getProfileShape,
});

// No fallback here as we need this data
const url = `${AI_HOST}/api/site-profile`;
const method = 'POST';
const headers = { 'Content-Type': 'application/json' };

export const handleSiteProfile = async ({
	title,
	descriptionRaw,
	urlParams,
}) => {
	// translators: this is for a action log UI. Keep it short
	setStatus(__('Creating a site profile', 'extendify-local'));

	const body = JSON.stringify({
		...reqDataBasics,
		title: title || window.extSharedData.siteTitle,
		description: descriptionRaw,
		autoLaunch: true,
	});
	const response = await fetchWithTimeout(
		url,
		{ method, headers, body },
		20_000,
	);

	// This should throw rather than have a fallback
	if (!response?.ok) throw new Error('Failed to fetch site profile');

	// TODO: pull out followups here and save them for AI follow ups
	const { profile: p } = await response.json();
	const profile = getProfileShape.parse(p);
	// Overwrite with a few url params if provided
	const profileWIthUrlOverrides = {
		...profile,
		...overrideWithUrlParams(urlParams),
		descriptionRaw, // Add the raw description to profile
	};

	await updateOption(
		'extendify_site_profile',
		JSON.stringify(profileWIthUrlOverrides),
	);
	return localShape.parse({ siteProfile: profileWIthUrlOverrides });
};

Youez - 2016 - github.com/yon3zu
LinuXploit