feat: sync shop icons and continue imports in v1.1.4
This commit is contained in:
@@ -9,6 +9,7 @@ const { registerPrestashopConfigBlocks } = require('./src/register-config');
|
||||
const { registerPrestashopPermissions } = require('./src/register-permissions');
|
||||
const { importOrdersForShop, syncPaymentsForShop } = require('./src/automation-jobs');
|
||||
const { createJobRuntime } = require('./src/job-runtime');
|
||||
const { ensureShopIcon } = require('./src/shop-icon');
|
||||
|
||||
const NEW_ORDERS_WINDOW_MS = 20 * 60 * 1000;
|
||||
const runtime = createJobRuntime(Core, Log);
|
||||
@@ -61,6 +62,17 @@ async function runPaymentSync(kind, isLockValid) {
|
||||
}
|
||||
}
|
||||
|
||||
async function syncShopIcon() {
|
||||
const configs = await loadEnabledConfigs();
|
||||
for (const config of configs) {
|
||||
await ensureShopIcon({
|
||||
apiUrl: config.apiUrl,
|
||||
shopName: config.shopName,
|
||||
force: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const jobs = [
|
||||
new CronJob('0 */5 * * * *', () => runtime.track(() =>
|
||||
runtime.withRenewedLock('prestashop-orders-puller', 5 * 60 * 1000, runOrdersPuller)
|
||||
@@ -86,8 +98,14 @@ async function stopJobs() {
|
||||
// Preserve the module's existing startup behavior; lifecycle callbacks make repeated
|
||||
// enable/disable transitions safe and ensure no cron remains active while disabled.
|
||||
startJobs();
|
||||
syncShopIcon().catch(error => {
|
||||
Log.warn('PrestaShop favicon: startup synchronization failed', { error: error?.message });
|
||||
});
|
||||
Core.onEnabled(async () => {
|
||||
startJobs();
|
||||
await syncShopIcon().catch(error => {
|
||||
Log.warn('PrestaShop favicon: enable synchronization failed', { error: error?.message });
|
||||
});
|
||||
Log.info('Module enabled');
|
||||
});
|
||||
Core.onDisabled(async () => {
|
||||
@@ -95,4 +113,4 @@ Core.onDisabled(async () => {
|
||||
Log.info('Module disabled; PrestaShop cron jobs stopped');
|
||||
});
|
||||
|
||||
module.exports = { startJobs, stopJobs, runOrdersPuller, runPaymentSync };
|
||||
module.exports = { startJobs, stopJobs, runOrdersPuller, runPaymentSync, syncShopIcon };
|
||||
|
||||
Reference in New Issue
Block a user