Skip to content

Commit

Permalink
Merge pull request #7 from JiaYingLii/web
Browse files Browse the repository at this point in the history
1. bug fix
  • Loading branch information
JiaYingLii authored Mar 11, 2024
2 parents cd26ba6 + f8e7a17 commit 22349c9
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions web/middleware/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from web.model.base import standard_error_response
from web.model.huixiangdou import HxdToken
from web.model.qalib import QalibInfo, Wechat
from web.service.qalib import QaLibCache, get_wechat_on_message_url
from web.service.qalib import QaLibCache, get_wechat_on_message_url, get_lark_on_message_url
from web.util.log import log

logger = log(__name__)
Expand All @@ -35,8 +35,26 @@ def check_hxd_token(request: Request) -> QalibInfo:
err_body = standard_error_response(biz_const.ERR_QALIB_INFO_NOT_FOUND)
raise HTTPException(status_code=200, detail=err_body.model_dump())

if not info.wechat or info.wechat.onMessageUrl.endswith("wechat"):
info.wechat = Wechat(onMessageUrl=get_wechat_on_message_url(info.suffix))
QaLibCache.set_qalib_info(hxd_token.jti, info)
check_endpoint_update(info)

return info


def check_endpoint_update(info: QalibInfo):
update = False
if not info.wechat or info.wechat.onMessageUrl.endswith("wechat"):
info.wechat = Wechat(onMessageUrl=get_wechat_on_message_url(info.suffix))
update = True
else:
wechat_message_url = get_wechat_on_message_url(info.suffix)
if info.wechat.onMessageUrl != wechat_message_url:
info.wechat.onMessageUrl = wechat_message_url
update = True

lark_event_url = get_lark_on_message_url()
if info.lark.eventUrl != lark_event_url:
info.lark.eventUrl = lark_event_url
update = True

if update:
QaLibCache.set_qalib_info(info.featureStoreId, info)

0 comments on commit 22349c9

Please sign in to comment.