增加微信内容审核接口

This commit is contained in:
zhl 2021-06-15 14:32:58 +08:00
parent cc7a2926ef
commit 6188b91220
2 changed files with 21 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import { generateQrFile } from '../../services/File'
import { getInviteeNum } from '../../services/JCFW'
import { UserItem } from '../../models/user/UserItem'
import { checkText } from '../../services/Baidu'
import { refreshToken } from '../../services/Wechat'
import { msgSecCheck, refreshToken } from '../../services/Wechat'
class GameController extends BaseController {
@role('anon')
@ -23,8 +23,10 @@ class GameController extends BaseController {
// return result
const { txt } = req.params
// const res = await checkText(txt)
const token = await refreshToken('wxf8c3da4e7dfe00a2', '8c0a1e88a6b43e4be80ed6a597c0b047')
return { token }
// const token = await refreshToken('wxf8c3da4e7dfe00a2', '8c0a1e88a6b43e4be80ed6a597c0b047')
// return { token }
const { data } = await msgSecCheck(txt)
return { data }
}
@permission(['game:read', 'shop:game_setting'])
@router('post /api/games')

View File

@ -43,4 +43,19 @@ export async function refreshToken(appId: string, appSecret: string) {
}
}
export async function msgSecCheck(content: string) {}
export async function msgSecCheck(content: string) {
let data = { content }
const token = await refreshToken('wxf8c3da4e7dfe00a2', '8c0a1e88a6b43e4be80ed6a597c0b047')
const url = `https://api.weixin.qq.com/wxa/msg_sec_check?access_token=${token}`
let reqConfig: AxiosRequestConfig = {
method: 'post',
url,
headers: {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json',
},
responseType: 'stream',
data,
}
return axios(reqConfig)
}