diff --git a/initdatas/activity_info.json b/initdatas/activity_info.json index d294d50..0a7a698 100644 --- a/initdatas/activity_info.json +++ b/initdatas/activity_info.json @@ -16,6 +16,7 @@ "cfg": {"icon": "twitter"}, "start": "2024-01-01 00:00", "end": "2025-01-01 00:00", + "checkChain": true, "params": {} }, { "id": "e2fclylj30vwcpe0szl", @@ -30,6 +31,7 @@ "cfg": {"account": "@_CounterFire", "icon": "twitter"}, "start": "2024-01-01 00:00", "end": "2025-01-01 00:00", + "checkChain": true, "params": {"time": 6, "failRate": 60} }, { "id": "e2feyflj30vwcpe0sjy", @@ -44,6 +46,7 @@ "cfg": {"icon": "twitter"}, "start": "2024-01-01 00:00", "end": "2025-01-01 00:00", + "checkChain": true, "params": {"time": 6, "failRate": 60} }, { "id": "e2fuah0j30vwcpe0my7", @@ -58,20 +61,7 @@ "cfg": {"icon": "twitter", "content": "Just joined Counter Fire! 🎮 Excited about the endless opportunities ahead. 🔥 Let's team up and conquer together! Come in with me #CounterFire #GamingAdventures"}, "start": "2024-01-01 00:00", "end": "2025-01-01 00:00", - "params": {"time": 6, "failRate": 60} - }, { - "id": "e2fuah0j30vwcpe1my7", - "task": "TwitterRetweet", - "title": "", - "type": 1, - "desc": "Click Verify button and retweet on the tweet", - "category": "Social Tasks", - "score": 200, - "autoclaim": false, - "pretasks": ["e2yhq2lj30vwcpedv7p"], - "cfg": {"icon": "twitter", "content": "输入框自动生成,活动开始时添加内容)"}, - "start": "2024-01-01 00:00", - "end": "2025-01-01 00:00", + "checkChain": true, "params": {"time": 6, "failRate": 60} } ], diff --git a/src/controllers/chest.controller.ts b/src/controllers/chest.controller.ts index a46fe8d..474e7b3 100644 --- a/src/controllers/chest.controller.ts +++ b/src/controllers/chest.controller.ts @@ -154,7 +154,6 @@ class BoxController extends BaseController { throw new ZError(13, 'waiting for chain confirm') } - // TODO:: 待规则确定后, 检查用户是否符合助力条件 const chest = await ActivityChest.findOne({ shareCode: code, activity: user.activity }) if (!chest) { throw new ZError(12, 'chest not found') diff --git a/src/controllers/game.controller.ts b/src/controllers/game.controller.ts index 9b5940c..ac7f9c6 100644 --- a/src/controllers/game.controller.ts +++ b/src/controllers/game.controller.ts @@ -317,7 +317,11 @@ class GameController extends BaseController { if (!isObjectId(id)) { throw new ZError(12, 'invalid id') } - const chainRecord = await GeneralScription.findOne({ from: user.address.toLowerCase(), op: 'explore', data: id }) + const chainRecord = await GeneralScription.findOne({ + from: user.address.toLowerCase(), + op: 'explore', + data: id, + }) if (!chainRecord) { throw new ZError(13, 'waiting for chain confirm') } diff --git a/src/controllers/tasks.controller.ts b/src/controllers/tasks.controller.ts index 61f92da..f3329d0 100644 --- a/src/controllers/tasks.controller.ts +++ b/src/controllers/tasks.controller.ts @@ -3,6 +3,7 @@ import { TaskCfg, TaskTypeEnum } from 'models/ActivityInfo' import { TaskStatus, TaskStatusEnum } from 'models/ActivityUser' import { join } from 'path' import { formatDate } from 'zutils/utils/date.util' +import { GeneralScription } from 'models/chain/GeneralScription' const fs = require('fs') const prod = process.env.NODE_ENV === 'production' @@ -191,6 +192,16 @@ export default class TasksController extends BaseController { if (currentTask.status !== TaskStatusEnum.SUCCESS && currentTask.status !== TaskStatusEnum.PART_SUCCESS) { throw new ZError(13, 'task not end') } + if (cfg.checkChain) { + const chainRecord = await GeneralScription.findOne({ + from: user.address.toLowerCase(), + op: 'task_claim', + data: task, + }) + if (!chainRecord) { + throw new ZError(14, 'waiting for chain confirm') + } + } const Task = require('../tasks/' + currentTask.task) const taskInstance = new Task.default({ user, activity }) diff --git a/src/models/ActivityInfo.ts b/src/models/ActivityInfo.ts index a323ae5..0688bfa 100644 --- a/src/models/ActivityInfo.ts +++ b/src/models/ActivityInfo.ts @@ -39,6 +39,8 @@ export class TaskCfg { end?: string @prop({ type: mongoose.Schema.Types.Mixed }) params: any + @prop({ default: true }) + checkChain: boolean public isStart() { const now = Date.now()