Fix not rebuilding site resources from blueprint

This commit is contained in:
Owen
2025-12-07 22:13:26 -05:00
parent e10f7efcbe
commit 24cdac95cd
2 changed files with 13 additions and 12 deletions

View File

@@ -133,15 +133,12 @@ export async function applyBlueprint({
`Updating client resource ${result.newSiteResource.siteResourceId} on site ${site.sites.siteId}`
);
if (result.oldSiteResource) {
// this was an update
await handleMessagingForUpdatedSiteResource(
result.oldSiteResource,
result.newSiteResource,
{ siteId: site.sites.siteId, orgId: site.sites.orgId },
trx
);
}
await handleMessagingForUpdatedSiteResource(
result.oldSiteResource,
result.newSiteResource,
{ siteId: site.sites.siteId, orgId: site.sites.orgId },
trx
);
// await addClientTargets(
// site.newt.newtId,
@@ -188,4 +185,4 @@ export async function applyBlueprint({
}
return blueprint;
}
}

View File

@@ -328,23 +328,27 @@ export async function updateSiteResource(
}
export async function handleMessagingForUpdatedSiteResource(
existingSiteResource: SiteResource,
existingSiteResource: SiteResource | undefined,
updatedSiteResource: SiteResource,
site: { siteId: number; orgId: string },
trx: Transaction
) {
const { mergedAllClients } =
await rebuildClientAssociationsFromSiteResource(
existingSiteResource, // we want to rebuild based on the existing resource then we will apply the change to the destination below
existingSiteResource || updatedSiteResource, // we want to rebuild based on the existing resource then we will apply the change to the destination below
trx
);
// after everything is rebuilt above we still need to update the targets and remote subnets if the destination changed
const destinationChanged =
existingSiteResource &&
existingSiteResource.destination !== updatedSiteResource.destination;
const aliasChanged =
existingSiteResource &&
existingSiteResource.alias !== updatedSiteResource.alias;
// if the existingSiteResource is undefined (new resource) we don't need to do anything here, the rebuild above handled it all
if (destinationChanged || aliasChanged) {
const [newt] = await trx
.select()