宝箱助力状态查询增加宝箱所有者信息
This commit is contained in:
parent
69529d610c
commit
f1501a25c3
17
docs/uaw.md
17
docs/uaw.md
@ -34,6 +34,13 @@
|
|||||||
1. 增加接口:我的助力记录(27)
|
1. 增加接口:我的助力记录(27)
|
||||||
2. 所有带用户信息的接口增加返回avatar(头像)字段
|
2. 所有带用户信息的接口增加返回avatar(头像)字段
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### 20240411
|
||||||
|
|
||||||
|
1. 宝箱助力状态查询(26) 增加返回宝箱所有者信息
|
||||||
|
2.
|
||||||
|
|
||||||
### 1. 钱包预登录
|
### 1. 钱包预登录
|
||||||
|
|
||||||
#### Request
|
#### Request
|
||||||
@ -734,7 +741,7 @@ body:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### 26.\* 宝箱助力状态查询
|
### 26.\ 宝箱助力状态查询
|
||||||
|
|
||||||
#### Request
|
#### Request
|
||||||
|
|
||||||
@ -757,11 +764,13 @@ body:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
userCurrent: 1, // 用户当日已助力次数
|
userCurrent: 1, // 用户当日已助力次数, 未登录用户可能为空
|
||||||
userMax: 10, // 用户当日最大可助力次数
|
userMax: 10, // 用户当日最大可助力次数, 未登录用户可能为空
|
||||||
|
enhanced: 0, // 用户是否已经为当前宝箱助力, 未登录用户可能为空
|
||||||
chestCurrent: 1, // 宝箱当前助力次数
|
chestCurrent: 1, // 宝箱当前助力次数
|
||||||
chestMax: 10, // 宝箱最大可助力次数
|
chestMax: 10, // 宝箱最大可助力次数
|
||||||
enhanced: 0, // 用户是否已经为当前宝箱助力
|
nickname: '11', // 宝箱所有者昵称
|
||||||
|
avatar: '', // 宝箱所有者头像, 可能为空
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
"start": "2024-01-01 00:00",
|
"start": "2024-01-01 00:00",
|
||||||
"end": "2025-01-01 00:00",
|
"end": "2025-01-01 00:00",
|
||||||
"checkChain": true,
|
"checkChain": true,
|
||||||
|
"base": true,
|
||||||
"params": {}
|
"params": {}
|
||||||
}, {
|
}, {
|
||||||
"id": "e2fclylj30vwcpe0szl",
|
"id": "e2fclylj30vwcpe0szl",
|
||||||
@ -32,6 +33,23 @@
|
|||||||
"start": "2024-01-01 00:00",
|
"start": "2024-01-01 00:00",
|
||||||
"end": "2025-01-01 00:00",
|
"end": "2025-01-01 00:00",
|
||||||
"checkChain": true,
|
"checkChain": true,
|
||||||
|
"base": true,
|
||||||
|
"params": {"time": 6, "failRate": 0}
|
||||||
|
},{
|
||||||
|
"id": "e2far3lj30vwcpe0mf8",
|
||||||
|
"task": "DiscordJoin",
|
||||||
|
"title": "Join Discord",
|
||||||
|
"type": 1,
|
||||||
|
"desc": "Join Counter Fire’s official Discord server",
|
||||||
|
"category": "Social Tasks",
|
||||||
|
"score": 100,
|
||||||
|
"autoclaim": false,
|
||||||
|
"pretasks": [],
|
||||||
|
"cfg": {"icon": "discord"},
|
||||||
|
"start": "2024-01-01 00:00",
|
||||||
|
"end": "2025-01-01 00:00",
|
||||||
|
"checkChain": true,
|
||||||
|
"base": true,
|
||||||
"params": {"time": 6, "failRate": 0}
|
"params": {"time": 6, "failRate": 0}
|
||||||
}, {
|
}, {
|
||||||
"id": "e2feyflj30vwcpe0sjy",
|
"id": "e2feyflj30vwcpe0sjy",
|
||||||
|
@ -124,6 +124,7 @@ class BoxController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 宝箱助力状态查询
|
* 宝箱助力状态查询
|
||||||
*/
|
*/
|
||||||
|
@role(ROLE_ANON)
|
||||||
@router('post /api/chest/enhance/state')
|
@router('post /api/chest/enhance/state')
|
||||||
async enhanceState(req) {
|
async enhanceState(req) {
|
||||||
const { code, chestId } = req.params
|
const { code, chestId } = req.params
|
||||||
@ -141,7 +142,7 @@ class BoxController extends BaseController {
|
|||||||
if (chestId) {
|
if (chestId) {
|
||||||
chest = await ActivityChest.findById(chestId)
|
chest = await ActivityChest.findById(chestId)
|
||||||
} else {
|
} else {
|
||||||
chest = await ActivityChest.findOne({ shareCode: code, activity: user.activity })
|
chest = await ActivityChest.findOne({ shareCode: code })
|
||||||
}
|
}
|
||||||
if (!chest) {
|
if (!chest) {
|
||||||
throw new ZError(12, 'chest not found')
|
throw new ZError(12, 'chest not found')
|
||||||
@ -152,17 +153,36 @@ class BoxController extends BaseController {
|
|||||||
if (chest.status === ChestStatusEnum.LOCKED) {
|
if (chest.status === ChestStatusEnum.LOCKED) {
|
||||||
throw new ZError(15, 'chest is locked')
|
throw new ZError(15, 'chest is locked')
|
||||||
}
|
}
|
||||||
const enhanced = chest.bonusUsers.includes(user.id) ? 1 : 0
|
const chestOwner = await ActivityUser.findById(chest.user)
|
||||||
const userMax = user.twitterId && user.discordId ? MAX_ENHANCE_COUNT_ADV : MAX_ENHANCE_COUNT_BASE
|
|
||||||
const dateTag = formatDate(new Date())
|
|
||||||
const userCurrent = await ChestEnhanceRecord.countDocuments({ user: user.id, activity: user.activity, dateTag })
|
|
||||||
|
|
||||||
return {
|
if (user) {
|
||||||
userCurrent,
|
const enhanced = chest.bonusUsers.includes(user.id) ? 1 : 0
|
||||||
userMax,
|
const userMax = user.twitterId && user.discordId ? MAX_ENHANCE_COUNT_ADV : MAX_ENHANCE_COUNT_BASE
|
||||||
enhanced,
|
const dateTag = formatDate(new Date())
|
||||||
chestCurrent: chest.bonusUsers.length,
|
const userCurrent = await ChestEnhanceRecord.countDocuments({ user: user.id, activity: user.activity, dateTag })
|
||||||
chestMax: chest.maxBounsCount,
|
|
||||||
|
return {
|
||||||
|
userCurrent,
|
||||||
|
userMax,
|
||||||
|
enhanced,
|
||||||
|
nickname:
|
||||||
|
chestOwner?.twitterName || chestOwner?.discordName || chestOwner?.address
|
||||||
|
? formatAddress(chestOwner.address)
|
||||||
|
: 'unknown',
|
||||||
|
avatar: chestOwner?.twitterAvatar || '',
|
||||||
|
chestCurrent: chest.bonusUsers.length,
|
||||||
|
chestMax: chest.maxBounsCount,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
chestCurrent: chest.bonusUsers.length,
|
||||||
|
chestMax: chest.maxBounsCount,
|
||||||
|
nickname:
|
||||||
|
chestOwner?.twitterName || chestOwner?.discordName || chestOwner?.address
|
||||||
|
? formatAddress(chestOwner.address)
|
||||||
|
: 'unknown',
|
||||||
|
avatar: chestOwner?.twitterAvatar || '',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ const apiAuthPlugin: FastifyPluginAsync<ApiAuthOptions> = async function (fastif
|
|||||||
})
|
})
|
||||||
// 只有路由配置的role为anon才不需要过滤
|
// 只有路由配置的role为anon才不需要过滤
|
||||||
fastify.decorate('apiAuth', async function (request: FastifyRequest, reply: FastifyReply) {
|
fastify.decorate('apiAuth', async function (request: FastifyRequest, reply: FastifyReply) {
|
||||||
if (!request.roles || request.roles.indexOf(ROLE_ANON) == -1) {
|
if (!request.roles || request.roles.indexOf(ROLE_ANON) == -1 || request.token) {
|
||||||
try {
|
try {
|
||||||
if (!request.token) {
|
if (!request.token) {
|
||||||
return reply.send({ errcode: 11, errmsg: 'need login' })
|
return reply.send({ errcode: 11, errmsg: 'need login' })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user