Merge branch 'master' into ai/issue-98
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
2026-10-16 14:31:39 +00:00
7 changed files with 115 additions and 14 deletions

View File

@@ -65,9 +65,9 @@ function resolveWorldAssets(fields, campaign) {
}
}
async function saveFoundryActor(campaign, source, fullSync = false) {
async function saveFoundryActor(campaign, source, fullSync = false, replace = false) {
const foundryActorId = String(source?._id || source?.id || '').trim().slice(0, 120);
const fields = foundryActorToCharacter(source || {});
const fields = foundryActorToCharacter(source || {}, replace);
if (!foundryActorId || !fields.name) return null;
resolveWorldAssets(fields, campaign);
@@ -305,12 +305,16 @@ router.post('/sync/snapshot', async (req, res) => {
}
const fullSync = req.body.fullSync === true;
// A forced actor sync from the module's context menu replaces the campaign's
// row for the actors it sends entirely (Syndria98/dragonroll#96). It stays
// clear of fullSync: it never prunes, unlike a reconnect's full snapshot.
const replace = req.body.replace === true;
// A module that knows nothing about item folders sends neither the tree
// nor the folder of an item, and then nothing here touches the folders.
const folderSources = Array.isArray(req.body.folders) ? req.body.folders : null;
const actors = [];
for (const source of actorSources || []) {
const mapping = await saveFoundryActor(campaign, source, fullSync);
const mapping = await saveFoundryActor(campaign, source, fullSync, replace);
if (mapping) actors.push(mapping);
}
const itemFolders = folderSources ? await syncFoundryItemFolders(campaign, folderSources) : null;