fix: clear cache for organizations when subscriptions updates

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-06-04 12:00:45 +02:00
parent 92210c1b3f
commit 5c5154ee86

View File

@@ -1,6 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { db } from '@openpanel/db';
import { db, getOrganizationByProjectIdCached } from '@openpanel/db';
import {
sendSlackNotification,
slackInstaller,
@@ -201,6 +201,16 @@ export async function polarWebhook(
},
});
const projects = await db.project.findMany({
where: {
organizationId: metadata.organizationId,
},
});
for (const project of projects) {
await getOrganizationByProjectIdCached.clear(project.id);
}
await publishEvent('organization', 'subscription_updated', {
organizationId: metadata.organizationId,
});