zhaoqingang
2024-11-25 c795d4b39ce86ad9b502044d96df9392c0c7dca7
app/service/bisheng.py
@@ -68,7 +68,8 @@
                {
                    "id": item["chat_id"],
                    "name": item["latest_message"]["message"],
                    "updated_time": int(datetime.strptime(item["update_time"], "%Y-%m-%dT%H:%M:%S").timestamp() * 1000)
                    "updated_time": int(datetime.strptime(item["update_time"], "%Y-%m-%dT%H:%M:%S").timestamp() * 1000),
                    "update_date": item["update_time"]
                }
                for item in data
                if "latest_message" in item and "message" in item["latest_message"] and item["latest_message"]["message"]
@@ -93,6 +94,7 @@
                {
                    "id": item["chat_id"],
                    "name": process_name(item),
                    "update_date": item["update_time"].replace("T", " "),
                    "updated_time": int(datetime.strptime(item["update_time"], "%Y-%m-%dT%H:%M:%S").timestamp() * 1000)
                }
                for item in data
@@ -156,3 +158,17 @@
            response = await client.get(url, headers=headers)
            data = self._check_response(response)
            return data
    async def change_password_public(self, token: str, username: str, password: str, new_password:str) -> dict:
        url = f"{self.base_url}/api/v1/user/change_password_public"
        headers = {'cookie': f"access_token_cookie={token};"}
        public_key = await self.get_public_key_api()
        password = BishengCrypto(public_key, settings.PRIVATE_KEY).encrypt(password)
        new_password = BishengCrypto(public_key, settings.PRIVATE_KEY).encrypt(new_password)
        json = {"username": username, "password": password, "new_password": new_password}
        async with httpx.AsyncClient() as client:
            response = await client.post(url, headers=headers, json=json)
            data = self._check_response(response)
            return data