koishi-plugin-blacklist-online 0.1.2 → 0.1.4

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.
Files changed (3) hide show
  1. package/lib/core.js +10 -5
  2. package/lib/index.js +10 -10
  3. package/package.json +1 -1
package/lib/core.js CHANGED
@@ -55,12 +55,17 @@ async function syncBlacklist(ctx, config) {
55
55
  return;
56
56
  }
57
57
  if (strategy === 'full_replace') {
58
- logger.info(`📥 全量同步 -> ${newRevision} (条数: ${data.length})`);
58
+ logger.info(`执行全量同步,条数: ${data.length}`);
59
+ // 1. 先清空本地表,确保环境干净
59
60
  await ctx.database.remove('blacklist_users', {});
60
- // 分批写入防报错
61
- const batchSize = 100;
62
- for (let i = 0; i < data.length; i += batchSize) {
63
- await ctx.database.upsert('blacklist_users', data.slice(i, i + batchSize));
61
+ // 2. 批量写入。由于我们定义了 primary: 'user_id',这里即便有重复也会直接覆盖
62
+ if (data.length > 0) {
63
+ // 分批处理,防止 SQLite 单次 SQL 语句过长
64
+ const batchSize = 100;
65
+ for (let i = 0; i < data.length; i += batchSize) {
66
+ const batch = data.slice(i, i + batchSize);
67
+ await ctx.database.upsert('blacklist_users', batch);
68
+ }
64
69
  }
65
70
  }
66
71
  else if (strategy === 'incremental') {
package/lib/index.js CHANGED
@@ -131,12 +131,12 @@ function apply(ctx, config) {
131
131
  return '❌ 该用户在本地白名单中,无法拉黑。';
132
132
  const requestId = (0, node_crypto_1.randomUUID)();
133
133
  const payload = {
134
- requestId: requestId,
134
+ request_id: requestId,
135
135
  type: 'ADD',
136
- applicantId: session.userId,
137
- targetUserId: userId,
136
+ applicant_id: session.userId,
137
+ target_user_id: userId,
138
138
  reason,
139
- guildId: session.guildId,
139
+ guild_id: session.guildId,
140
140
  timestamp: Date.now()
141
141
  };
142
142
  try {
@@ -161,10 +161,10 @@ function apply(ctx, config) {
161
161
  const userId = (0, core_1.parseUserId)(user);
162
162
  const requestId = (0, node_crypto_1.randomUUID)();
163
163
  const payload = {
164
- requestId: requestId,
164
+ request_id: requestId,
165
165
  type: 'REMOVE',
166
- applicantId: session.userId,
167
- targetUserId: userId,
166
+ applicant_id: session.userId,
167
+ target_user_id: userId,
168
168
  reason,
169
169
  timestamp: Date.now()
170
170
  };
@@ -185,9 +185,9 @@ function apply(ctx, config) {
185
185
  if (!uuid)
186
186
  return '请输入要撤回的申请 UUID。';
187
187
  const payload = {
188
- requestId: (0, node_crypto_1.randomUUID)(),
189
- targetRequestId: uuid,
190
- applicantId: session?.userId,
188
+ request_id: (0, node_crypto_1.randomUUID)(),
189
+ target_request_id: uuid,
190
+ applicant_id: session?.userId,
191
191
  timestamp: Date.now()
192
192
  };
193
193
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-blacklist-online",
3
3
  "description": "自用插件",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [