fix: 移除扫码页出证总开关
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- Certificates are requested explicitly by the consumer; no global pause switch.
|
||||
DELETE FROM `system_setting` WHERE `key` = 'certificateEnabled';
|
||||
@@ -2,7 +2,7 @@ import { DepositCertificateService } from './deposit-certificate.service';
|
||||
import { DepositProvider } from './deposit.provider';
|
||||
|
||||
const settings = {
|
||||
certificateEnabled: 'true', blockchainDriver: 'tianhe',
|
||||
blockchainDriver: 'tianhe',
|
||||
tianheEnv: 'test', tianheAppId: 'app', tianheAppKey: 'key', tianheWalletAddress: '0x' + 'a'.repeat(40),
|
||||
};
|
||||
function fixture(state = 'PENDING') {
|
||||
@@ -78,9 +78,9 @@ describe('Consumer certificate lifecycle', () => {
|
||||
await expect(service.request('123456000001')).rejects.toThrow();
|
||||
expect(prisma.$transaction).not.toHaveBeenCalled();
|
||||
});
|
||||
it('ignores obsolete daily settings and claims an item without any quota transaction', async () => {
|
||||
it('ignores the obsolete disabled switch and daily settings when claiming an item', async () => {
|
||||
const { service, prisma, config } = fixture('NONE');
|
||||
config.getAllRaw.mockResolvedValue({ ...settings, certificateDailyLimit: '0', certificateDailyQuota: '2026-09-20:999999' } as any);
|
||||
config.getAllRaw.mockResolvedValue({ ...settings, certificateEnabled: 'false', certificateDailyLimit: '0', certificateDailyQuota: '2026-09-20:999999' } as any);
|
||||
await service.request('123456000001');
|
||||
expect(prisma.blockchainProof.updateMany).toHaveBeenCalledWith(expect.objectContaining({
|
||||
where: { id: 1, certificateState: 'NONE', status: 'ONCHAIN' },
|
||||
|
||||
@@ -61,7 +61,6 @@ export class DepositCertificateService {
|
||||
const { code, proof } = await this.eligible(shortCode);
|
||||
if (proof.certificateState === 'READY') return this.view(proof);
|
||||
const settings = await this.settings.getAllRaw();
|
||||
if (settings.certificateEnabled === 'false') throw new BusinessException(ErrorCode.BAD_REQUEST, '证书生成暂时关闭');
|
||||
if (proof.certificateState !== 'NONE') {
|
||||
// An uncertain submission is never submitted again. User action only resumes queries.
|
||||
if (proof.certificateState === 'UNKNOWN' && (!proof.certificateNextCheck || proof.certificateNextCheck <= new Date())) {
|
||||
@@ -109,7 +108,6 @@ export class DepositCertificateService {
|
||||
if (this.running) return;
|
||||
this.running = true;
|
||||
try {
|
||||
if ((await this.settings.get('certificateEnabled')) === 'false') return;
|
||||
const now = new Date();
|
||||
const rows = await this.prisma.blockchainProof.findMany({
|
||||
where: { certificateState: { in: ACTIVE_STATES }, certificateNextCheck: { lte: now },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'crypto';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
@@ -29,7 +29,6 @@ const EDITABLE_KEYS = [
|
||||
'storageMigrationFingerprint',
|
||||
'storageMigrationCopied',
|
||||
'blockchainDriver',
|
||||
'certificateEnabled',
|
||||
'tianheEnv',
|
||||
'tianheBaseUrl',
|
||||
'tianheAppId',
|
||||
@@ -90,7 +89,6 @@ export class SettingsService {
|
||||
ossAccessKeySecret: this.config.get<string>('storage.oss.accessKeySecret') || '',
|
||||
settingsEncryptionKey: this.config.get<string>('settingsEncryptionKey') || '',
|
||||
blockchainDriver: this.config.get<string>('blockchain.driver') || 'mock',
|
||||
certificateEnabled: 'true',
|
||||
tianheEnv: 'test',
|
||||
tianheBaseUrl: this.config.get<string>('blockchain.tianhe.baseUrl') || 'https://test.api.tichain.tianhecloud.com',
|
||||
tianheAppId: this.config.get<string>('blockchain.tianhe.appId') || '',
|
||||
@@ -144,9 +142,6 @@ export class SettingsService {
|
||||
}
|
||||
|
||||
async updateAtomic(values: Record<string, string>): Promise<void> {
|
||||
if (values.certificateEnabled !== undefined && !['true', 'false'].includes(String(values.certificateEnabled))) {
|
||||
throw new BadRequestException('Invalid certificate switch');
|
||||
}
|
||||
const updates: Array<{ key: string; value: string }> = [];
|
||||
for (const [key, value] of Object.entries(values)) {
|
||||
if (!EDITABLE_KEYS.includes(key)) continue;
|
||||
|
||||
Reference in New Issue
Block a user