sycommon-python-lib 0.2.6a1__py3-none-any.whl → 0.2.6a2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -271,24 +271,19 @@ class WeComLDAPService(metaclass=SingletonMeta):
271
271
  async def _get_bot_access_token(self) -> str:
272
272
  """获取用于 open_userid 解码的 access_token
273
273
 
274
- 本地开发(IS_DEV=true)时,使用 WeComDecodeUserID 配置的凭据,
275
- 线上直接使用 WeCom 配置的凭据。
274
+ 始终使用 WeComDecodeUserID 配置的凭据。
275
+ WeCom 通讯录 token 用于查用户/部门;
276
+ WeComDecodeUserID token 专用于 batch/openuserid_to_userid 解码。
276
277
  """
277
- import os
278
278
  from sycommon.config.Config import Config
279
279
 
280
- is_dev = os.environ.get("IS_DEV") == "true"
281
280
  config = Config().config.get("llm", {})
282
-
283
- if is_dev:
284
- wecom_config = config.get("WeComDecodeUserID", {}) or config.get("WeCom", {})
285
- else:
286
- wecom_config = config.get("WeCom", {})
281
+ wecom_config = config.get("WeComDecodeUserID", {})
287
282
 
288
283
  corpid = wecom_config.get("corpid", "")
289
284
  corpsecret = wecom_config.get("corpsecret", "")
290
285
  if not corpid or not corpsecret:
291
- raise ValueError("解码凭据配置不完整,需要配置 llm.WeComDecodeUserID 或 llm.WeCom")
286
+ raise ValueError("解码凭据配置不完整,需要配置 llm.WeComDecodeUserID")
292
287
 
293
288
  url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
294
289
  params = {"corpid": corpid, "corpsecret": corpsecret}
@@ -375,10 +370,11 @@ class WeComLDAPService(metaclass=SingletonMeta):
375
370
  async def _get_wecom_user(self, userid: str) -> Optional[dict]:
376
371
  """获取单个企微用户详情
377
372
 
378
- IS_DEV=true 时使用 WeComDecodeUserID token,
379
- 线上使用 WeCom token。
373
+ 始终使用 WeCom 通讯录 token 查询用户详情。
374
+ 注意:WeComDecodeUserID token 只能用于 open_userid 解码,
375
+ 不能查 /cgi-bin/user/get(会返回 errcode 60111)。
380
376
  """
381
- token = await self._get_bot_access_token()
377
+ token = await self._get_access_token()
382
378
  url = f"https://qyapi.weixin.qq.com/cgi-bin/user/get"
383
379
  async with aiohttp.ClientSession() as session:
384
380
  async with session.get(url, params={"access_token": token, "userid": userid}) as resp:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.2.6a1
3
+ Version: 0.2.6a2
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -147,7 +147,7 @@ sycommon/auth/ldap_service.py,sha256=fOcpVov5LWJkBk62qbTaltks1c4la7JsbD104KfdBOI
147
147
  sycommon/auth/oa_cache.py,sha256=u673y-mK-xo24pSqvfjL68_YFASO2zoxd_iAQ0HetCo,3491
148
148
  sycommon/auth/oa_crypto.py,sha256=xpY1R1Bj3KLENXB0TuThB6Eku1E9PYjcoSpOdgDmCgc,1898
149
149
  sycommon/auth/oa_service.py,sha256=kLepV9zgqpZoaB73DRPpMA5tJJQjoaDtQPdzBcGXeak,6235
150
- sycommon/auth/wecom_ldap_service.py,sha256=lo_t3sSQAYSGVofg1xe3YQik7VsI2ItFNZLxLVqlJmw,30530
150
+ sycommon/auth/wecom_ldap_service.py,sha256=8mCOClbdlvky58ISXmV4UfSfUF0aWmPWykACNgjgfTg,30488
151
151
  sycommon/config/Config.py,sha256=J5VjolqHmhYTBZwTyfSHv9X5cHMfN6kqY2ryHF4LJPw,6785
152
152
  sycommon/config/DatabaseConfig.py,sha256=ILiUuYT9_xJZE2W-RYuC3JCt_YLKc1sbH13-MHIOPhg,804
153
153
  sycommon/config/ElasticsearchConfig.py,sha256=fO9ZPMgJxSg1-UyDJ90wO6UvYy-jscwPJsSkXgx9qTU,2308
@@ -282,8 +282,8 @@ sycommon/tools/syemail.py,sha256=BDFhgf7WDOQeTcjxJEQdu0dQhnHFPO_p3eI0-Ni3LhQ,561
282
282
  sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
283
283
  sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
284
284
  sycommon/xxljob/xxljob_service.py,sha256=JIEJaGXhqrTLcyxlyynSrsHg9bBnDNzX-D4qIWLRPUE,6815
285
- sycommon_python_lib-0.2.6a1.dist-info/METADATA,sha256=kubGNvAaxxgtJBUXszJQbZLD5CZwm29ACii7lzTJWMM,7913
286
- sycommon_python_lib-0.2.6a1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
287
- sycommon_python_lib-0.2.6a1.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
288
- sycommon_python_lib-0.2.6a1.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
289
- sycommon_python_lib-0.2.6a1.dist-info/RECORD,,
285
+ sycommon_python_lib-0.2.6a2.dist-info/METADATA,sha256=Utz4dW5hwd9N97fayxjevOMQ-wweDQZ2H_YdlsJmKl4,7913
286
+ sycommon_python_lib-0.2.6a2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
287
+ sycommon_python_lib-0.2.6a2.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
288
+ sycommon_python_lib-0.2.6a2.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
289
+ sycommon_python_lib-0.2.6a2.dist-info/RECORD,,