소스 검색

Fix user_manager: MySQLUserManager get default

StrayWarrior 2 주 전
부모
커밋
afd9235190
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      agent_service.py
  2. 5 2
      user_manager.py

+ 1 - 1
agent_service.py

@@ -227,7 +227,7 @@ if __name__ == "__main__":
     # 初始化用户管理服务
     # FIXME(zhoutian): 如果不使用MySQL,此数据库配置非必须
     user_db_config = config['storage']['user']
-    if config['debug_flags'].get('use_local_user_manager', False):
+    if config['debug_flags'].get('use_local_user_storage', False):
         user_manager = LocalUserManager()
     else:
         user_manager = MySQLUserManager(user_db_config['mysql'], user_db_config['table'])

+ 5 - 2
user_manager.py

@@ -111,7 +111,9 @@ class MySQLUserManager(UserManager):
             logging.warning(f"user[{user_id}] profile not found, create a default one")
             default_profile = self.get_default_profile(nickname=data['name'])
             self.save_user_profile(user_id, default_profile)
-        return json.loads(data['profile_data_v1'])
+            return default_profile
+        else:
+            return json.loads(data['profile_data_v1'])
 
     def save_user_profile(self, user_id, profile: Dict) -> None:
         if not user_id:
@@ -180,7 +182,8 @@ class MySQLUserRelationManager(UserRelationManager):
                 sql = f"SELECT third_party_user_id, wxid FROM {self.agent_user_table} WHERE wxid IN {str(batch_union_ids)}"
                 batch_agent_user_data = self.agent_db.select(sql, pymysql.cursors.DictCursor)
                 if len(agent_user_data) != len(batch_union_ids):
-                    logging.error(f"staff[{wxid}] some users not found in agent database")
+                    # logging.debug(f"staff[{wxid}] some users not found in agent database")
+                    pass
                 agent_user_data.extend(batch_agent_user_data)
             staff_user_pairs = [
                 {