fix: wrong status code (400 -> 403)
This commit is contained in:
@@ -41,7 +41,7 @@ export default class ChatApi extends BaseApi {
|
|||||||
msg: "对话不存在",
|
msg: "对话不存在",
|
||||||
}
|
}
|
||||||
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
||||||
code: 400,
|
code: 403,
|
||||||
msg: "用户无权访问此对话",
|
msg: "用户无权访问此对话",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ export default class ChatApi extends BaseApi {
|
|||||||
msg: "对话不存在",
|
msg: "对话不存在",
|
||||||
}
|
}
|
||||||
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
||||||
code: 400,
|
code: 403,
|
||||||
msg: "用户无权访问此对话",
|
msg: "用户无权访问此对话",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ export default class ChatApi extends BaseApi {
|
|||||||
msg: "对话不存在",
|
msg: "对话不存在",
|
||||||
}
|
}
|
||||||
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
||||||
code: 400,
|
code: 403,
|
||||||
msg: "用户无权访问此对话",
|
msg: "用户无权访问此对话",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ export default class ChatApi extends BaseApi {
|
|||||||
msg: "对话不存在",
|
msg: "对话不存在",
|
||||||
}
|
}
|
||||||
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
||||||
code: 400,
|
code: 403,
|
||||||
msg: "用户无权访问此对话",
|
msg: "用户无权访问此对话",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +240,44 @@ export default class ChatApi extends BaseApi {
|
|||||||
}
|
}
|
||||||
const chat = ChatPrivate.findOrCreateForPrivate(user, targetUser)
|
const chat = ChatPrivate.findOrCreateForPrivate(user, targetUser)
|
||||||
|
|
||||||
|
return {
|
||||||
|
code: 200,
|
||||||
|
msg: '成功',
|
||||||
|
data: {
|
||||||
|
chat_id: chat.bean.id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* 加入群组
|
||||||
|
* @param token 令牌
|
||||||
|
* @param target ID
|
||||||
|
*/
|
||||||
|
this.registerEvent("Chat.requestToBeMemberOfGroup", (args, { deviceId }) => {
|
||||||
|
if (this.checkArgsMissing(args, ['token', 'target'])) return {
|
||||||
|
msg: "参数缺失",
|
||||||
|
code: 400,
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = TokenManager.decode(args.token as string)
|
||||||
|
if (!this.checkToken(token, deviceId)) return {
|
||||||
|
code: 401,
|
||||||
|
msg: "令牌无效",
|
||||||
|
}
|
||||||
|
const user = User.findById(token.author) as User
|
||||||
|
|
||||||
|
const chat = Chat.findById(args.target as string)
|
||||||
|
if (chat == null) return {
|
||||||
|
code: 404,
|
||||||
|
msg: "对话不存在",
|
||||||
|
}
|
||||||
|
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
||||||
|
code: 403,
|
||||||
|
msg: "用户无权访问此对话",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
code: 200,
|
code: 200,
|
||||||
msg: '成功',
|
msg: '成功',
|
||||||
@@ -359,7 +397,7 @@ export default class ChatApi extends BaseApi {
|
|||||||
msg: "对话不存在",
|
msg: "对话不存在",
|
||||||
}
|
}
|
||||||
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
if (!UserChatLinker.checkUserIsLinkedToChat(token.author, chat!.bean.id)) return {
|
||||||
code: 400,
|
code: 403,
|
||||||
msg: "用户无权访问此对话",
|
msg: "用户无权访问此对话",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user