fix: 去除share
This commit is contained in:
@@ -15,21 +15,17 @@ const ChatSchema = new Schema({
|
||||
expiredTime: {
|
||||
// 过期时间
|
||||
type: Number,
|
||||
required: true
|
||||
default: Date.now()
|
||||
},
|
||||
loadAmount: {
|
||||
// 剩余加载次数
|
||||
type: Number,
|
||||
required: true
|
||||
default: -1
|
||||
},
|
||||
updateTime: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
},
|
||||
isShare: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
content: {
|
||||
type: [
|
||||
{
|
||||
|
||||
@@ -26,13 +26,9 @@ export const authChat = async (chatId: string, authorization?: string) => {
|
||||
}
|
||||
|
||||
// 凭证校验
|
||||
if (!chat.isShare) {
|
||||
const userId = await authToken(authorization);
|
||||
if (userId !== String(chat.userId._id)) {
|
||||
return Promise.reject('无权使用该对话');
|
||||
}
|
||||
} else if (chat.loadAmount === 0 || chat.expiredTime <= Date.now()) {
|
||||
return Promise.reject('聊天框已过期');
|
||||
const userId = await authToken(authorization);
|
||||
if (userId !== String(chat.userId._id)) {
|
||||
return Promise.reject('无权使用该对话');
|
||||
}
|
||||
|
||||
// 获取 user 的 apiKey
|
||||
|
||||
Reference in New Issue
Block a user