You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4KB

  1. from flask_restful import Resource, reqparse
  2. from flask import jsonify,request,json
  3. from common import redis_helper,utils
  4. from wechat import gewe_chat
  5. import threading
  6. class GetGroupsInfoResource(Resource):
  7. def __init__(self):
  8. self.parser = reqparse.RequestParser()
  9. self.wxchat = gewe_chat.wxchat
  10. def post(self):
  11. req = request.get_json()
  12. wxid = req.get("wxid")
  13. groups=self.wxchat.get_groups_info_from_cache(wxid)
  14. return jsonify(groups)
  15. class GetGroupMemberList(Resource):
  16. def __init__(self):
  17. self.parser = reqparse.RequestParser()
  18. self.wxchat = gewe_chat.wxchat
  19. def post(self):
  20. req = request.get_json()
  21. wxid = req.get("wxid")
  22. chatroom_id=req.get("chatroomId")
  23. _,loginfo=utils.get_login_info_by_wxid(wxid)
  24. token_id=loginfo.get('tokenId')
  25. app_id=loginfo.get('appId')
  26. ret, msg, data = self.wxchat.get_group_memberlist(token_id, app_id, chatroom_id)
  27. if ret != 200:
  28. response = jsonify({
  29. 'code': ret,
  30. 'message': msg
  31. })
  32. response.status_code = ret
  33. response.message = msg
  34. return response
  35. thread = threading.Thread(target=self.wxchat.save_groups_members_to_cache, args=(token_id, app_id,wxid, [chatroom_id]))
  36. thread.start()
  37. return jsonify(data)