@@ -30,7 +30,7 @@ app.all('*', (_, res, next) => {
30
30
31
31
router . get ( '/chatrooms' , auth , async ( req , res ) => {
32
32
try {
33
- const userId = new ObjectId ( req . headers . userId as string )
33
+ const userId = req . headers . userId as string
34
34
const rooms = await getChatRooms ( userId )
35
35
const result = [ ]
36
36
rooms . forEach ( ( r ) => {
@@ -50,7 +50,7 @@ router.get('/chatrooms', auth, async (req, res) => {
50
50
51
51
router . post ( '/room-create' , auth , async ( req , res ) => {
52
52
try {
53
- const userId = new ObjectId ( req . headers . userId as string )
53
+ const userId = req . headers . userId as string
54
54
const { title, roomId } = req . body as { title : string ; roomId : number }
55
55
const room = await createChatRoom ( userId , title , roomId )
56
56
res . send ( { status : 'Success' , message : null , data : room } )
@@ -63,7 +63,7 @@ router.post('/room-create', auth, async (req, res) => {
63
63
64
64
router . post ( '/room-rename' , auth , async ( req , res ) => {
65
65
try {
66
- const userId = new ObjectId ( req . headers . userId as string )
66
+ const userId = req . headers . userId as string
67
67
const { title, roomId } = req . body as { title : string ; roomId : number }
68
68
const room = await renameChatRoom ( userId , title , roomId )
69
69
res . send ( { status : 'Success' , message : null , data : room } )
@@ -76,7 +76,7 @@ router.post('/room-rename', auth, async (req, res) => {
76
76
77
77
router . post ( '/room-delete' , auth , async ( req , res ) => {
78
78
try {
79
- const userId = new ObjectId ( req . headers . userId as string )
79
+ const userId = req . headers . userId as string
80
80
const { roomId } = req . body as { roomId : number }
81
81
if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
82
82
res . send ( { status : 'Fail' , message : 'Unknow room' , data : null } )
@@ -93,7 +93,7 @@ router.post('/room-delete', auth, async (req, res) => {
93
93
94
94
router . get ( '/chat-hisroty' , auth , async ( req , res ) => {
95
95
try {
96
- const userId = new ObjectId ( req . headers . userId as string )
96
+ const userId = req . headers . userId as string
97
97
const roomId = + req . query . roomid
98
98
const lastTime = req . query . lasttime as string
99
99
if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
@@ -146,7 +146,7 @@ router.get('/chat-hisroty', auth, async (req, res) => {
146
146
147
147
router . post ( '/chat-delete' , auth , async ( req , res ) => {
148
148
try {
149
- const userId = new ObjectId ( req . headers . userId as string )
149
+ const userId = req . headers . userId as string
150
150
const { roomId, uuid, inversion } = req . body as { roomId : number ; uuid : number ; inversion : boolean }
151
151
if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
152
152
res . send ( { status : 'Fail' , message : 'Unknow room' , data : null } )
@@ -163,7 +163,7 @@ router.post('/chat-delete', auth, async (req, res) => {
163
163
164
164
router . post ( '/chat-clear-all' , auth , async ( req , res ) => {
165
165
try {
166
- const userId = new ObjectId ( req . headers . userId as string )
166
+ const userId = req . headers . userId as string
167
167
await deleteAllChatRooms ( userId )
168
168
res . send ( { status : 'Success' , message : null , data : null } )
169
169
}
@@ -175,7 +175,7 @@ router.post('/chat-clear-all', auth, async (req, res) => {
175
175
176
176
router . post ( '/chat-clear' , auth , async ( req , res ) => {
177
177
try {
178
- const userId = new ObjectId ( req . headers . userId as string )
178
+ const userId = req . headers . userId as string
179
179
const { roomId } = req . body as { roomId : number }
180
180
if ( ! roomId || ! await existsChatRoom ( userId , roomId ) ) {
181
181
res . send ( { status : 'Fail' , message : 'Unknow room' , data : null } )
@@ -426,7 +426,7 @@ router.post('/setting-mail', rootAuth, async (req, res) => {
426
426
router . post ( '/mail-test' , rootAuth , async ( req , res ) => {
427
427
try {
428
428
const config = req . body as MailConfig
429
- const userId = new ObjectId ( req . headers . userId as string )
429
+ const userId = req . headers . userId as string
430
430
const user = await getUserById ( userId )
431
431
await sendTestMail ( user . email , config )
432
432
res . send ( { status : 'Success' , message : '发送成功 | Successfully' , data : null } )
0 commit comments