feat: 檢驗用戶的 設備 ID

This commit is contained in:
CrescentLeaf
2025-09-21 12:28:44 +08:00
parent 83719f5f44
commit e5dd3ade51
9 changed files with 67 additions and 38 deletions

View File

@@ -15,14 +15,14 @@ export default class ChatApi extends BaseApi {
* @param token 令牌
* @param target 目標對話
*/
this.registerEvent("Chat.getInfo", (args) => {
this.registerEvent("Chat.getInfo", (args, { deviceId }) => {
if (this.checkArgsMissing(args, ['token', 'target'])) return {
msg: "參數缺失",
code: 400,
}
const token = TokenManager.decode(args.token as string)
if (!this.checkToken(token)) return {
if (!this.checkToken(token, deviceId)) return {
code: 401,
msg: "令牌無效",
}
@@ -59,14 +59,14 @@ export default class ChatApi extends BaseApi {
* @param target 目標對話
* @param
*/
this.registerEvent("Chat.sendMessage", (args) => {
this.registerEvent("Chat.sendMessage", (args, { deviceId }) => {
if (this.checkArgsMissing(args, ['token', 'target'])) return {
msg: "參數缺失",
code: 400,
}
const token = TokenManager.decode(args.token as string)
if (!this.checkToken(token)) return {
if (!this.checkToken(token, deviceId)) return {
code: 401,
msg: "令牌無效",
}
@@ -82,14 +82,14 @@ export default class ChatApi extends BaseApi {
* @param target 目標對話
* @param page 頁面
*/
this.registerEvent("Chat.getMessageHistory", (args) => {
this.registerEvent("Chat.getMessageHistory", (args, { deviceId }) => {
if (this.checkArgsMissing(args, ['token', 'target', 'page'])) return {
msg: "參數缺失",
code: 400,
}
const token = TokenManager.decode(args.token as string)
if (!this.checkToken(token)) return {
if (!this.checkToken(token, deviceId)) return {
code: 401,
msg: "令牌無效",
}