|
|
@@ -59,7 +59,26 @@ class GetFriendsInfoResource(Resource): |
|
|
|
def post(self): |
|
|
|
req = request.get_json() |
|
|
|
wxid = req.get("wxid") |
|
|
|
cache=self.wxchat.get_contacts_brief_from_cache(wxid) |
|
|
|
# cache_str=redis_helper.redis_helper.get_hash_field(f'__AI_OPS_WX__:CONTACTS_BRIEF:{wxid}','data') |
|
|
|
# cache = json.loads(cache_str) if cache_str else [] |
|
|
|
return jsonify(cache) |
|
|
|
cache = req.get("cache",True) |
|
|
|
_,loginfo=utils.get_login_info_by_wxid(wxid) |
|
|
|
token_id=loginfo.get('tokenId') |
|
|
|
app_id=loginfo.get('appId') |
|
|
|
|
|
|
|
if cache: |
|
|
|
cache=self.wxchat.get_contacts_brief_from_cache(wxid) |
|
|
|
# cache_str=redis_helper.redis_helper.get_hash_field(f'__AI_OPS_WX__:CONTACTS_BRIEF:{wxid}','data') |
|
|
|
# cache = json.loads(cache_str) if cache_str else [] |
|
|
|
return jsonify(cache) |
|
|
|
else: |
|
|
|
ret,msg,contacts_list=self.wxchat.fetch_contacts_list(token_id,app_id) |
|
|
|
if ret!=200: |
|
|
|
response=jsonify({ |
|
|
|
'code':ret, |
|
|
|
'message':msg |
|
|
|
}) |
|
|
|
response.status_code=ret |
|
|
|
return response |
|
|
|
friend_wxids = [c for c in contacts_list['friends'] if c not in ['fmessage', 'medianote','weixin','weixingongzhong']] # 可以调整截取范围 |
|
|
|
data=self.wxchat.save_contacts_brief_to_cache(token_id, app_id, wxid, friend_wxids) |
|
|
|
print(f'{wxid}获取实时好友信息') |
|
|
|
return jsonify(data) |