Skip to content

Commit

Permalink
fix(nuxt3): get stargram bot config
Browse files Browse the repository at this point in the history
  • Loading branch information
LarchLiu committed Feb 6, 2024
1 parent 9652849 commit 48a36de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
15 changes: 11 additions & 4 deletions server/nuxt3/server/api/defaultBotConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ export default eventHandler(async (event) => {
encodeConfig = telegramConfig[id].config
}
else {
const slackConfig = await getBotConfig('slack')
if (slackConfig.default) {
const id = slackConfig.default
encodeConfig = slackConfig[id].config
const stargramConfig = await getBotConfig('stargram')
if (stargramConfig.default) {
const id = stargramConfig.default
encodeConfig = stargramConfig[id].config
}
else {
const slackConfig = await getBotConfig('slack')
if (slackConfig.default) {
const id = slackConfig.default
encodeConfig = slackConfig[id].config
}
}
}
return { config: encodeConfig }
Expand Down
17 changes: 13 additions & 4 deletions server/nuxt3/server/api/webcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ export default eventHandler(async (event) => {
imgConfig = botConfig.imgStorage.config
}
else {
const slackConfig = await getBotConfig('slack')
if (slackConfig.default) {
const id = slackConfig.default
botConfig = JSON.parse(cryption.decode(slackConfig[id].config)) as ServerConfig<OutUserConfig>
const stargramConfig = await getBotConfig('stargram')
if (stargramConfig.default) {
const id = stargramConfig.default
botConfig = JSON.parse(cryption.decode(stargramConfig[id].config)) as ServerConfig<OutUserConfig>
fnName = botConfig.imgStorage.select
imgConfig = botConfig.imgStorage.config
}
else {
const slackConfig = await getBotConfig('slack')
if (slackConfig.default) {
const id = slackConfig.default
botConfig = JSON.parse(cryption.decode(slackConfig[id].config)) as ServerConfig<OutUserConfig>
fnName = botConfig.imgStorage.select
imgConfig = botConfig.imgStorage.config
}
}
}
if (!fnName || !imgConfig) {
setResponseStatus(event, 400)
Expand Down

0 comments on commit 48a36de

Please sign in to comment.