koishi-plugin-group-verification 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +74 -39
- package/package.json +1 -1
- package/src/index.ts +100 -65
package/lib/index.d.ts
CHANGED
|
@@ -100,4 +100,5 @@ export declare function verifyApplication(config: GroupVerificationConfig, messa
|
|
|
100
100
|
matchedCount: number;
|
|
101
101
|
requiredThreshold: string;
|
|
102
102
|
}>;
|
|
103
|
+
export declare function handleFailedVerification(ctx: Context, session: any, config: GroupVerificationConfig, matchedCount?: number, requiredThreshold?: string): Promise<void>;
|
|
103
104
|
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Config: () => Config,
|
|
24
24
|
apply: () => apply,
|
|
25
|
+
handleFailedVerification: () => handleFailedVerification,
|
|
25
26
|
inject: () => inject,
|
|
26
27
|
mergeReminder: () => mergeReminder,
|
|
27
28
|
name: () => name,
|
|
@@ -287,6 +288,39 @@ async function verifyApplication(config, message, session) {
|
|
|
287
288
|
return { isValid, matchedCount, requiredThreshold };
|
|
288
289
|
}
|
|
289
290
|
__name(verifyApplication, "verifyApplication");
|
|
291
|
+
async function handleFailedVerification(ctx, session, config, matchedCount, requiredThreshold) {
|
|
292
|
+
const guildId = (session.guildId || session.channelId || "").toString().trim();
|
|
293
|
+
const userId = session.userId;
|
|
294
|
+
const username = session.username || "未知用户";
|
|
295
|
+
const message = session.content || "";
|
|
296
|
+
logger.info(`处理失败验证 guild=${guildId} user=${userId} msg="${message}" matched=${matchedCount} threshold=${requiredThreshold}`);
|
|
297
|
+
if (matchedCount === void 0 || requiredThreshold === void 0) {
|
|
298
|
+
const result = await verifyApplication(config, message, session);
|
|
299
|
+
matchedCount = result.matchedCount;
|
|
300
|
+
requiredThreshold = result.requiredThreshold;
|
|
301
|
+
}
|
|
302
|
+
let groupName = "未知群组";
|
|
303
|
+
try {
|
|
304
|
+
const guild = await session.bot.getGuild(guildId);
|
|
305
|
+
groupName = guild.name || groupName;
|
|
306
|
+
} catch (error) {
|
|
307
|
+
}
|
|
308
|
+
await ctx.database.create("group_verification_pending", {
|
|
309
|
+
groupId: guildId,
|
|
310
|
+
userId,
|
|
311
|
+
userName: username,
|
|
312
|
+
requestMessage: message,
|
|
313
|
+
applyTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
314
|
+
});
|
|
315
|
+
if (!config.reminderEnabled || !config.reminderMessage || config.reminderMessage === "") {
|
|
316
|
+
logger.info(`群 ${guildId} 的提醒消息已被禁用,跳过发送`);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
let reminderMsg = config.reminderMessage;
|
|
320
|
+
reminderMsg = reminderMsg.replace(/{user}/g, username).replace(/{id}/g, userId).replace(/{group}/g, guildId).replace(/{gname}/g, groupName).replace(/{question}/g, message).replace(/{answer}/g, matchedCount.toString()).replace(/{threshold}/g, requiredThreshold);
|
|
321
|
+
await ctx.broadcast([guildId], reminderMsg);
|
|
322
|
+
}
|
|
323
|
+
__name(handleFailedVerification, "handleFailedVerification");
|
|
290
324
|
function apply(ctx, config) {
|
|
291
325
|
ctx.model.extend("group_verification_config", {
|
|
292
326
|
id: "unsigned",
|
|
@@ -367,7 +401,7 @@ function apply(ctx, config) {
|
|
|
367
401
|
}
|
|
368
402
|
}
|
|
369
403
|
} else {
|
|
370
|
-
await handleFailedVerification(ctx, session, config2);
|
|
404
|
+
await handleFailedVerification(ctx, session, config2, matchedCount, requiredThreshold);
|
|
371
405
|
}
|
|
372
406
|
});
|
|
373
407
|
ctx.on("guild-member-added", async (session) => {
|
|
@@ -393,39 +427,6 @@ function apply(ctx, config) {
|
|
|
393
427
|
logger.info(`用户 ${userId} 被手动邀请加入群 ${groupId},手动批准统计已更新`);
|
|
394
428
|
}
|
|
395
429
|
});
|
|
396
|
-
async function handleFailedVerification(ctx2, session, config2, matchedCount, requiredThreshold) {
|
|
397
|
-
const guildId = (session.guildId || session.channelId || "").toString().trim();
|
|
398
|
-
const userId = session.userId;
|
|
399
|
-
const username = session.username || "未知用户";
|
|
400
|
-
const message = session.content || "";
|
|
401
|
-
logger.info(`处理失败验证 guild=${guildId} user=${userId} msg="${message}" matched=${matchedCount} threshold=${requiredThreshold}`);
|
|
402
|
-
if (matchedCount === void 0 || requiredThreshold === void 0) {
|
|
403
|
-
const result = await verifyApplication(config2, message, session);
|
|
404
|
-
matchedCount = result.matchedCount;
|
|
405
|
-
requiredThreshold = result.requiredThreshold;
|
|
406
|
-
}
|
|
407
|
-
let groupName = "未知群组";
|
|
408
|
-
try {
|
|
409
|
-
const guild = await session.bot.getGuild(guildId);
|
|
410
|
-
groupName = guild.name || groupName;
|
|
411
|
-
} catch (error) {
|
|
412
|
-
}
|
|
413
|
-
await ctx2.database.create("group_verification_pending", {
|
|
414
|
-
groupId: guildId,
|
|
415
|
-
userId,
|
|
416
|
-
userName: username,
|
|
417
|
-
requestMessage: message,
|
|
418
|
-
applyTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
419
|
-
});
|
|
420
|
-
if (!config2.reminderEnabled || !config2.reminderMessage || config2.reminderMessage === "") {
|
|
421
|
-
logger.info(`群 ${guildId} 的提醒消息已被禁用,跳过发送`);
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
let reminderMsg = config2.reminderMessage;
|
|
425
|
-
reminderMsg = reminderMsg.replace(/{user}/g, username).replace(/{id}/g, userId).replace(/{group}/g, guildId).replace(/{gname}/g, groupName).replace(/{question}/g, message).replace(/{answer}/g, matchedCount.toString()).replace(/{threshold}/g, requiredThreshold);
|
|
426
|
-
await ctx2.broadcast([guildId], reminderMsg);
|
|
427
|
-
}
|
|
428
|
-
__name(handleFailedVerification, "handleFailedVerification");
|
|
429
430
|
async function updateStats(groupId, action) {
|
|
430
431
|
const existingStats = await ctx.database.get("group_verification_stats", { groupId });
|
|
431
432
|
if (existingStats.length > 0) {
|
|
@@ -716,7 +717,7 @@ gvc -r # 删除配置`;
|
|
|
716
717
|
await ctx.database.set("group_verification_config", { id: existingConfig.id }, {
|
|
717
718
|
reviewParameters,
|
|
718
719
|
updatedBy: session.username || session.userId,
|
|
719
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
720
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
720
721
|
});
|
|
721
722
|
logger.info(`已更新数据库阈值为: ${reviewParameters}`);
|
|
722
723
|
} else {
|
|
@@ -735,17 +736,20 @@ gvc -r # 删除配置`;
|
|
|
735
736
|
reminderEnabled,
|
|
736
737
|
reminderMessage,
|
|
737
738
|
updatedBy: session.username || session.userId,
|
|
738
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
739
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
739
740
|
};
|
|
740
741
|
if (existingConfig) {
|
|
741
|
-
await ctx.database.set("group_verification_config", { id: existingConfig.id },
|
|
742
|
+
await ctx.database.set("group_verification_config", { id: existingConfig.id }, {
|
|
743
|
+
...dbData,
|
|
744
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
745
|
+
});
|
|
742
746
|
logger.info(`更新配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`);
|
|
743
747
|
} else {
|
|
744
748
|
await ctx.database.create("group_verification_config", {
|
|
745
749
|
groupId: targetGroupId,
|
|
746
750
|
...dbData,
|
|
747
751
|
createdBy: session.username || session.userId,
|
|
748
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
752
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
749
753
|
});
|
|
750
754
|
logger.info(`创建配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`);
|
|
751
755
|
}
|
|
@@ -1051,6 +1055,36 @@ gvc -r # 删除配置`;
|
|
|
1051
1055
|
- 私聊时必须指定群号(-i参数)`;
|
|
1052
1056
|
});
|
|
1053
1057
|
ctx.on("ready", async () => {
|
|
1058
|
+
try {
|
|
1059
|
+
const configs = await ctx.database.get("group_verification_config", {});
|
|
1060
|
+
for (const cfg of configs) {
|
|
1061
|
+
const updates = {};
|
|
1062
|
+
if (cfg.createdAt instanceof Date) updates.createdAt = cfg.createdAt.toISOString();
|
|
1063
|
+
if (cfg.updatedAt instanceof Date) updates.updatedAt = cfg.updatedAt.toISOString();
|
|
1064
|
+
if (Object.keys(updates).length) {
|
|
1065
|
+
await ctx.database.set("group_verification_config", { id: cfg.id }, updates);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
const stats = await ctx.database.get("group_verification_stats", {});
|
|
1069
|
+
for (const st of stats) {
|
|
1070
|
+
const updates = {};
|
|
1071
|
+
if (st.lastUpdated instanceof Date) updates.lastUpdated = st.lastUpdated.toISOString();
|
|
1072
|
+
if (Object.keys(updates).length) {
|
|
1073
|
+
await ctx.database.set("group_verification_stats", { id: st.id }, updates);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const pendings = await ctx.database.get("group_verification_pending", {});
|
|
1077
|
+
for (const p of pendings) {
|
|
1078
|
+
const updates = {};
|
|
1079
|
+
if (p.applyTime instanceof Date) updates.applyTime = p.applyTime.toISOString();
|
|
1080
|
+
if (Object.keys(updates).length) {
|
|
1081
|
+
await ctx.database.set("group_verification_pending", { id: p.id }, updates);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
logger.info("旧版日期字段迁移完成");
|
|
1085
|
+
} catch (e) {
|
|
1086
|
+
logger.warn("迁移旧日期字段时出错", e);
|
|
1087
|
+
}
|
|
1054
1088
|
const totalStats = await ctx.database.get("group_verification_stats", { groupId: "TOTAL" });
|
|
1055
1089
|
if (totalStats.length === 0) {
|
|
1056
1090
|
await ctx.database.create("group_verification_stats", {
|
|
@@ -1058,7 +1092,7 @@ gvc -r # 删除配置`;
|
|
|
1058
1092
|
autoApproved: 0,
|
|
1059
1093
|
manuallyApproved: 0,
|
|
1060
1094
|
rejected: 0,
|
|
1061
|
-
lastUpdated: /* @__PURE__ */ new Date()
|
|
1095
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
1062
1096
|
});
|
|
1063
1097
|
logger.info("已创建总计统计行");
|
|
1064
1098
|
} else {
|
|
@@ -1122,6 +1156,7 @@ __name(apply, "apply");
|
|
|
1122
1156
|
0 && (module.exports = {
|
|
1123
1157
|
Config,
|
|
1124
1158
|
apply,
|
|
1159
|
+
handleFailedVerification,
|
|
1125
1160
|
inject,
|
|
1126
1161
|
mergeReminder,
|
|
1127
1162
|
name,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -405,6 +405,64 @@ export async function verifyApplication(config: GroupVerificationConfig, message
|
|
|
405
405
|
return { isValid, matchedCount, requiredThreshold }
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
// 处理验证失败的情况并发送提醒消息(可由 tests 调用)
|
|
409
|
+
export async function handleFailedVerification(
|
|
410
|
+
ctx: Context,
|
|
411
|
+
session: any,
|
|
412
|
+
config: GroupVerificationConfig,
|
|
413
|
+
matchedCount?: number,
|
|
414
|
+
requiredThreshold?: string
|
|
415
|
+
) {
|
|
416
|
+
const guildId = (session.guildId || session.channelId || '').toString().trim();
|
|
417
|
+
const userId = session.userId
|
|
418
|
+
const username = session.username || '未知用户'
|
|
419
|
+
const message = session.content || ''
|
|
420
|
+
logger.info(`处理失败验证 guild=${guildId} user=${userId} msg="${message}" matched=${matchedCount} threshold=${requiredThreshold}`)
|
|
421
|
+
// 如果未传入匹配信息,则重新计算一次(老调用)
|
|
422
|
+
if (matchedCount === undefined || requiredThreshold === undefined) {
|
|
423
|
+
const result = await verifyApplication(config, message, session)
|
|
424
|
+
matchedCount = result.matchedCount
|
|
425
|
+
requiredThreshold = result.requiredThreshold
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// 获取群信息
|
|
429
|
+
let groupName = '未知群组'
|
|
430
|
+
try {
|
|
431
|
+
const guild = await session.bot.getGuild(guildId)
|
|
432
|
+
groupName = guild.name || groupName
|
|
433
|
+
} catch (error) {
|
|
434
|
+
// 无法获取群名称时使用默认值
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// 将申请加入待审核列表
|
|
438
|
+
await ctx.database.create('group_verification_pending', {
|
|
439
|
+
groupId: guildId,
|
|
440
|
+
userId: userId,
|
|
441
|
+
userName: username,
|
|
442
|
+
requestMessage: message,
|
|
443
|
+
applyTime: new Date().toISOString()
|
|
444
|
+
})
|
|
445
|
+
// 如果提醒消息被禁用,直接返回
|
|
446
|
+
if (!config.reminderEnabled || !config.reminderMessage || config.reminderMessage === '') {
|
|
447
|
+
logger.info(`群 ${guildId} 的提醒消息已被禁用,跳过发送`)
|
|
448
|
+
return
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// 替换提醒消息中的变量
|
|
452
|
+
let reminderMsg = config.reminderMessage
|
|
453
|
+
reminderMsg = reminderMsg
|
|
454
|
+
.replace(/{user}/g, username)
|
|
455
|
+
.replace(/{id}/g, userId)
|
|
456
|
+
.replace(/{group}/g, guildId)
|
|
457
|
+
.replace(/{gname}/g, groupName)
|
|
458
|
+
.replace(/{question}/g, message)
|
|
459
|
+
.replace(/{answer}/g, matchedCount!.toString())
|
|
460
|
+
.replace(/{threshold}/g, requiredThreshold!)
|
|
461
|
+
|
|
462
|
+
// 发送提醒消息到群内
|
|
463
|
+
await ctx.broadcast([guildId], reminderMsg)
|
|
464
|
+
}
|
|
465
|
+
|
|
408
466
|
export function apply(ctx: Context, config: Config) {
|
|
409
467
|
// 创建数据库表
|
|
410
468
|
ctx.model.extend('group_verification_config', {
|
|
@@ -511,7 +569,7 @@ export function apply(ctx: Context, config: Config) {
|
|
|
511
569
|
}
|
|
512
570
|
}
|
|
513
571
|
} else {
|
|
514
|
-
await handleFailedVerification(ctx, session, config);
|
|
572
|
+
await handleFailedVerification(ctx, session, config, matchedCount, requiredThreshold);
|
|
515
573
|
}
|
|
516
574
|
});
|
|
517
575
|
|
|
@@ -548,65 +606,6 @@ export function apply(ctx: Context, config: Config) {
|
|
|
548
606
|
}
|
|
549
607
|
})
|
|
550
608
|
|
|
551
|
-
// 处理验证失败的情况
|
|
552
|
-
// 处理验证失败的情况并发送提醒消息
|
|
553
|
-
// matchedCount/requiredThreshold 可选,为空时内部重新计算(兼容旧调用)
|
|
554
|
-
async function handleFailedVerification(
|
|
555
|
-
ctx: Context,
|
|
556
|
-
session: any,
|
|
557
|
-
config: GroupVerificationConfig,
|
|
558
|
-
matchedCount?: number,
|
|
559
|
-
requiredThreshold?: string
|
|
560
|
-
) {
|
|
561
|
-
const guildId = (session.guildId || session.channelId || '').toString().trim();
|
|
562
|
-
const userId = session.userId
|
|
563
|
-
const username = session.username || '未知用户'
|
|
564
|
-
const message = session.content || ''
|
|
565
|
-
logger.info(`处理失败验证 guild=${guildId} user=${userId} msg="${message}" matched=${matchedCount} threshold=${requiredThreshold}`)
|
|
566
|
-
// 如果未传入匹配信息,则重新计算一次(老调用)
|
|
567
|
-
if (matchedCount === undefined || requiredThreshold === undefined) {
|
|
568
|
-
const result = await verifyApplication(config, message, session)
|
|
569
|
-
matchedCount = result.matchedCount
|
|
570
|
-
requiredThreshold = result.requiredThreshold
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// 获取群信息
|
|
574
|
-
let groupName = '未知群组'
|
|
575
|
-
try {
|
|
576
|
-
const guild = await session.bot.getGuild(guildId)
|
|
577
|
-
groupName = guild.name || groupName
|
|
578
|
-
} catch (error) {
|
|
579
|
-
// 无法获取群名称时使用默认值
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// 将申请加入待审核列表
|
|
583
|
-
await ctx.database.create('group_verification_pending', {
|
|
584
|
-
groupId: guildId,
|
|
585
|
-
userId: userId,
|
|
586
|
-
userName: username,
|
|
587
|
-
requestMessage: message,
|
|
588
|
-
applyTime: new Date().toISOString()
|
|
589
|
-
})
|
|
590
|
-
// 如果提醒消息被禁用,直接返回
|
|
591
|
-
if (!config.reminderEnabled || !config.reminderMessage || config.reminderMessage === '') {
|
|
592
|
-
logger.info(`群 ${guildId} 的提醒消息已被禁用,跳过发送`)
|
|
593
|
-
return
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
// 替换提醒消息中的变量
|
|
597
|
-
let reminderMsg = config.reminderMessage
|
|
598
|
-
reminderMsg = reminderMsg
|
|
599
|
-
.replace(/{user}/g, username)
|
|
600
|
-
.replace(/{id}/g, userId)
|
|
601
|
-
.replace(/{group}/g, guildId)
|
|
602
|
-
.replace(/{gname}/g, groupName)
|
|
603
|
-
.replace(/{question}/g, message)
|
|
604
|
-
.replace(/{answer}/g, matchedCount!.toString())
|
|
605
|
-
.replace(/{threshold}/g, requiredThreshold!)
|
|
606
|
-
|
|
607
|
-
// 发送提醒消息到群内
|
|
608
|
-
await ctx.broadcast([guildId], reminderMsg)
|
|
609
|
-
}
|
|
610
609
|
|
|
611
610
|
|
|
612
611
|
// 更新统计信息
|
|
@@ -1008,7 +1007,7 @@ gvc -r # 删除配置`
|
|
|
1008
1007
|
await ctx.database.set('group_verification_config', { id: existingConfig.id }, {
|
|
1009
1008
|
reviewParameters: reviewParameters,
|
|
1010
1009
|
updatedBy: session.username || session.userId,
|
|
1011
|
-
updatedAt: new Date()
|
|
1010
|
+
updatedAt: new Date().toISOString()
|
|
1012
1011
|
})
|
|
1013
1012
|
logger.info(`已更新数据库阈值为: ${reviewParameters}`)
|
|
1014
1013
|
} else {
|
|
@@ -1034,18 +1033,22 @@ gvc -r # 删除配置`
|
|
|
1034
1033
|
reminderEnabled: reminderEnabled,
|
|
1035
1034
|
reminderMessage: reminderMessage,
|
|
1036
1035
|
updatedBy: session.username || session.userId,
|
|
1037
|
-
updatedAt: new Date()
|
|
1036
|
+
updatedAt: new Date().toISOString()
|
|
1038
1037
|
}
|
|
1039
1038
|
|
|
1040
1039
|
if (existingConfig) {
|
|
1041
|
-
|
|
1040
|
+
// ensure timestamp strings for compatibility
|
|
1041
|
+
await ctx.database.set('group_verification_config', { id: existingConfig.id }, {
|
|
1042
|
+
...dbData,
|
|
1043
|
+
updatedAt: new Date().toISOString(),
|
|
1044
|
+
})
|
|
1042
1045
|
logger.info(`更新配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`)
|
|
1043
1046
|
} else {
|
|
1044
1047
|
await ctx.database.create('group_verification_config', {
|
|
1045
1048
|
groupId: targetGroupId,
|
|
1046
1049
|
...dbData,
|
|
1047
1050
|
createdBy: session.username || session.userId,
|
|
1048
|
-
createdAt: new Date()
|
|
1051
|
+
createdAt: new Date().toISOString()
|
|
1049
1052
|
})
|
|
1050
1053
|
logger.info(`创建配置成功 - 审核方式: ${reviewMethod}, 阈值: ${reviewParameters}`)
|
|
1051
1054
|
}
|
|
@@ -1428,6 +1431,38 @@ gvc -r # 删除配置`
|
|
|
1428
1431
|
|
|
1429
1432
|
// 插件初始化时确保总计统计行存在
|
|
1430
1433
|
ctx.on('ready', async () => {
|
|
1434
|
+
// 迁移:将旧版保留的 Date 对象字段转换为 ISO 字符串,以避免绑定错误
|
|
1435
|
+
try {
|
|
1436
|
+
const configs = await ctx.database.get('group_verification_config', {})
|
|
1437
|
+
for (const cfg of configs) {
|
|
1438
|
+
const updates: any = {}
|
|
1439
|
+
if (cfg.createdAt instanceof Date) updates.createdAt = cfg.createdAt.toISOString()
|
|
1440
|
+
if (cfg.updatedAt instanceof Date) updates.updatedAt = cfg.updatedAt.toISOString()
|
|
1441
|
+
if (Object.keys(updates).length) {
|
|
1442
|
+
await ctx.database.set('group_verification_config', { id: cfg.id }, updates)
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
const stats = await ctx.database.get('group_verification_stats', {})
|
|
1446
|
+
for (const st of stats) {
|
|
1447
|
+
const updates: any = {}
|
|
1448
|
+
if (st.lastUpdated instanceof Date) updates.lastUpdated = st.lastUpdated.toISOString()
|
|
1449
|
+
if (Object.keys(updates).length) {
|
|
1450
|
+
await ctx.database.set('group_verification_stats', { id: st.id }, updates)
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
const pendings = await ctx.database.get('group_verification_pending', {})
|
|
1454
|
+
for (const p of pendings) {
|
|
1455
|
+
const updates: any = {}
|
|
1456
|
+
if (p.applyTime instanceof Date) updates.applyTime = p.applyTime.toISOString()
|
|
1457
|
+
if (Object.keys(updates).length) {
|
|
1458
|
+
await ctx.database.set('group_verification_pending', { id: p.id }, updates)
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
logger.info('旧版日期字段迁移完成')
|
|
1462
|
+
} catch (e) {
|
|
1463
|
+
logger.warn('迁移旧日期字段时出错', e)
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1431
1466
|
// 检查是否已存在总计行(groupId为'TOTAL')
|
|
1432
1467
|
const totalStats = await ctx.database.get('group_verification_stats', { groupId: 'TOTAL' })
|
|
1433
1468
|
|
|
@@ -1438,7 +1473,7 @@ gvc -r # 删除配置`
|
|
|
1438
1473
|
autoApproved: 0,
|
|
1439
1474
|
manuallyApproved: 0,
|
|
1440
1475
|
rejected: 0,
|
|
1441
|
-
lastUpdated: new Date()
|
|
1476
|
+
lastUpdated: new Date().toISOString()
|
|
1442
1477
|
})
|
|
1443
1478
|
logger.info('已创建总计统计行')
|
|
1444
1479
|
} else {
|