@@ -16,7 +16,7 @@ import { router as promptRouter } from './routes/prompt'
1616import { router as roomRouter } from './routes/room'
1717import { router as uploadRouter } from './routes/upload'
1818import { clearApiKeyCache , clearConfigCache , getApiKeys , getCacheApiKeys , getCacheConfig , getOriginConfig } from './storage/config'
19- import { AdvancedConfig , Status , UserConfig , UserRole } from './storage/model'
19+ import { Status , UserConfig , UserRole } from './storage/model'
2020import {
2121 createUser ,
2222 disableUser2FA ,
@@ -33,7 +33,6 @@ import {
3333 updateGiftCards ,
3434 updateUser ,
3535 updateUser2FA ,
36- updateUserAdvancedConfig ,
3736 updateUserAmount ,
3837 updateUserChatModel ,
3938 updateUserInfo ,
@@ -169,7 +168,7 @@ router.post('/session', async (req, res) => {
169168 // Parse external chat sites list
170169 const externalChatSites : Array < { name : string , url : string } > = config . siteConfig . externalChatSites || [ ]
171170
172- let userInfo : { name : string , description : string , avatar : string , userId : string , root : boolean , roles : UserRole [ ] , config : UserConfig , advanced : AdvancedConfig }
171+ let userInfo : { name : string , description : string , avatar : string , userId : string , root : boolean , roles : UserRole [ ] , config : UserConfig }
173172 if ( userId != null ) {
174173 const user = await getUserById ( userId )
175174 if ( user === null ) {
@@ -254,7 +253,6 @@ router.post('/session', async (req, res) => {
254253 root : user . roles . includes ( UserRole . Admin ) ,
255254 roles : user . roles ,
256255 config : user . config ,
257- advanced : user . advanced ,
258256 }
259257
260258 const keys = ( await getCacheApiKeys ( ) ) . filter ( d => hasAnyRole ( d . userRoles , user . roles ) )
@@ -987,46 +985,6 @@ router.post('/search-test', rootAuth, async (req, res) => {
987985 }
988986} )
989987
990- router . post ( '/setting-advanced' , auth , async ( req , res ) => {
991- try {
992- const config = req . body as {
993- systemMessage : string
994- sync : boolean
995- }
996- if ( config . sync ) {
997- if ( ! isAdmin ( req . headers . userId as string ) ) {
998- res . send ( { status : 'Fail' , message : '无权限 | No permission' , data : null } )
999- return
1000- }
1001- const thisConfig = await getOriginConfig ( )
1002- thisConfig . advancedConfig = new AdvancedConfig (
1003- config . systemMessage ,
1004- )
1005- await updateConfig ( thisConfig )
1006- clearConfigCache ( )
1007- }
1008- const userId = req . headers . userId . toString ( )
1009- await updateUserAdvancedConfig ( userId , new AdvancedConfig (
1010- config . systemMessage ,
1011- ) )
1012- res . send ( { status : 'Success' , message : '操作成功 | Successfully' } )
1013- }
1014- catch ( error ) {
1015- res . send ( { status : 'Fail' , message : error . message , data : null } )
1016- }
1017- } )
1018-
1019- router . post ( '/setting-reset-advanced' , auth , async ( req , res ) => {
1020- try {
1021- const userId = req . headers . userId . toString ( )
1022- await updateUserAdvancedConfig ( userId , null )
1023- res . send ( { status : 'Success' , message : '操作成功 | Successfully' } )
1024- }
1025- catch ( error ) {
1026- res . send ( { status : 'Fail' , message : error . message , data : null } )
1027- }
1028- } )
1029-
1030988router . get ( '/setting-keys' , rootAuth , async ( req , res ) => {
1031989 try {
1032990 const result = await getApiKeys ( )
0 commit comments