@@ -30,7 +30,7 @@ app.all('*', (_, res, next) => {
3030
3131router . get ( '/chatrooms' , auth , async ( req , res ) => {
3232 try {
33- const userId = new ObjectId ( req . headers . userId as string )
33+ const userId = req . headers . userId as string
3434 const rooms = await getChatRooms ( userId )
3535 const result = [ ]
3636 rooms . forEach ( ( r ) => {
@@ -50,7 +50,7 @@ router.get('/chatrooms', auth, async (req, res) => {
5050
5151router . post ( '/room-create' , auth , async ( req , res ) => {
5252 try {
53- const userId = new ObjectId ( req . headers . userId as string )
53+ const userId = req . headers . userId as string
5454 const { title, roomId } = req . body as { title : string ; roomId : number }
5555 const room = await createChatRoom ( userId , title , roomId )
5656 res . send ( { status : 'Success' , message : null , data : room } )
@@ -63,7 +63,7 @@ router.post('/room-create', auth, async (req, res) => {
6363
6464router . post ( '/room-rename' , auth , async ( req , res ) => {
6565 try {
66- const userId = new ObjectId ( req . headers . userId as string )
66+ const userId = req . headers . userId as string
6767 const { title, roomId } = req . body as { title : string ; roomId : number }
6868 const room = await renameChatRoom ( userId , title , roomId )
6969 res . send ( { status : 'Success' , message : null , data : room } )
@@ -76,7 +76,7 @@ router.post('/room-rename', auth, async (req, res) => {
7676
7777router . post ( '/room-delete' , auth , async ( req , res ) => {
7878 try {
79- const userId = new ObjectId ( req . headers . userId as string )
79+ const userId = req . headers . userId as string
8080 const { roomId } = req . body as { roomId : number }
8181 if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
8282 res . send ( { status : 'Fail' , message : 'Unknow room' , data : null } )
@@ -93,7 +93,7 @@ router.post('/room-delete', auth, async (req, res) => {
9393
9494router . get ( '/chat-hisroty' , auth , async ( req , res ) => {
9595 try {
96- const userId = new ObjectId ( req . headers . userId as string )
96+ const userId = req . headers . userId as string
9797 const roomId = + req . query . roomid
9898 const lastTime = req . query . lasttime as string
9999 if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
@@ -146,7 +146,7 @@ router.get('/chat-hisroty', auth, async (req, res) => {
146146
147147router . post ( '/chat-delete' , auth , async ( req , res ) => {
148148 try {
149- const userId = new ObjectId ( req . headers . userId as string )
149+ const userId = req . headers . userId as string
150150 const { roomId, uuid, inversion } = req . body as { roomId : number ; uuid : number ; inversion : boolean }
151151 if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
152152 res . send ( { status : 'Fail' , message : 'Unknow room' , data : null } )
@@ -163,7 +163,7 @@ router.post('/chat-delete', auth, async (req, res) => {
163163
164164router . post ( '/chat-clear-all' , auth , async ( req , res ) => {
165165 try {
166- const userId = new ObjectId ( req . headers . userId as string )
166+ const userId = req . headers . userId as string
167167 await deleteAllChatRooms ( userId )
168168 res . send ( { status : 'Success' , message : null , data : null } )
169169 }
@@ -175,7 +175,7 @@ router.post('/chat-clear-all', auth, async (req, res) => {
175175
176176router . post ( '/chat-clear' , auth , async ( req , res ) => {
177177 try {
178- const userId = new ObjectId ( req . headers . userId as string )
178+ const userId = req . headers . userId as string
179179 const { roomId } = req . body as { roomId : number }
180180 if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
181181 res . send ( { status : 'Fail' , message : 'Unknow room' , data : null } )
@@ -426,7 +426,7 @@ router.post('/setting-mail', rootAuth, async (req, res) => {
426426router . post ( '/mail-test' , rootAuth , async ( req , res ) => {
427427 try {
428428 const config = req . body as MailConfig
429- const userId = new ObjectId ( req . headers . userId as string )
429+ const userId = req . headers . userId as string
430430 const user = await getUserById ( userId )
431431 await sendTestMail ( user . email , config )
432432 res . send ( { status : 'Success' , message : '发送成功 | Successfully' , data : null } )
0 commit comments