feat(server): improve calendar sync queue (#14783)

This commit is contained in:
DarkSky
2026-04-05 11:05:35 +08:00
parent 46e7e35357
commit 43704d60fb
5 changed files with 339 additions and 133 deletions
+2 -3
View File
@@ -110,7 +110,7 @@
"react-dom": "19.2.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"semver": "^7.7.3",
"semver": "^7.7.4",
"ses": "^1.14.0",
"socket.io": "^4.8.1",
"stripe": "^17.7.0",
@@ -138,8 +138,7 @@
"@types/nodemailer": "^7.0.0",
"@types/on-headers": "^1.0.3",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@types/semver": "^7.5.8",
"@types/semver": "^7.7.1",
"@types/sinon": "^21.0.0",
"@types/supertest": "^6.0.2",
"ava": "^6.4.0",
@@ -6,6 +6,7 @@ import { AppModule } from '../app.module';
import {
CANARY_CLIENT_VERSION_MAX_AGE_DAYS,
ConfigFactory,
hasNewerVersion,
UseNamedGuard,
} from '../base';
import { Public } from '../core/auth/guard';
@@ -249,3 +250,11 @@ test('should reject old canary date version in canary namespace', async t => {
env.NAMESPACE = prevNamespace;
}
});
test('should compare release versions for available upgrades', t => {
t.false(hasNewerVersion('0.26.5', '0.26.4'));
t.false(hasNewerVersion('0.26.5', '0.26.5'));
t.true(hasNewerVersion('0.26.5', '0.26.6'));
t.true(hasNewerVersion('0.26.5', '0.26.6-beta.1'));
t.false(hasNewerVersion('0.26.6-beta.2', '0.26.6-beta.1'));
});
@@ -1,3 +1,5 @@
import semver from 'semver';
const DAY_MS = 24 * 60 * 60 * 1000;
// Example: 2026.2.6-canary.015
@@ -89,3 +91,26 @@ export function checkCanaryDateClientVersion(
normalized: parsed.normalized,
};
}
function normalizeComparableVersion(version: string): string | null {
const canary = parseCanaryDateClientVersion(version);
return semver.valid(canary?.normalized ?? version.trim(), {
loose: true,
});
}
export function hasNewerVersion(
currentVersion: string,
nextVersion: string
): boolean {
const current = normalizeComparableVersion(currentVersion);
const next = normalizeComparableVersion(nextVersion);
if (!current || !next) {
return currentVersion.trim() !== nextVersion.trim();
}
return semver.gt(next, current, {
loose: true,
});
}
@@ -12,7 +12,7 @@ import {
} from '@nestjs/graphql';
import { GraphQLJSON, GraphQLJSONObject } from 'graphql-scalars';
import { Config, URLHelper } from '../../base';
import { Config, hasNewerVersion, URLHelper } from '../../base';
import { Namespace } from '../../env';
import { Feature, type WorkspaceFeatureName } from '../../models';
import { CurrentUser, Public } from '../auth';
@@ -143,7 +143,7 @@ export class ServerConfigResolver {
}>;
const latest = releases.at(0);
if (!latest || latest.name === env.version) {
if (!latest || !hasNewerVersion(env.version, latest.name)) {
return null;
}