处理 wechat server 推送消息 :params msg: 加密内容 :params msg_signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数
(self, msg, msg_signature, timestamp, nonce)
| 524 | ) |
| 525 | |
| 526 | def parse_message(self, msg, msg_signature, timestamp, nonce): |
| 527 | """ |
| 528 | 处理 wechat server 推送消息 |
| 529 | |
| 530 | :params msg: 加密内容 |
| 531 | :params msg_signature: 消息签名 |
| 532 | :params timestamp: 时间戳 |
| 533 | :params nonce: 随机数 |
| 534 | """ |
| 535 | content = self.crypto.decrypt_message(msg, msg_signature, timestamp, nonce) |
| 536 | message = xmltodict.parse(to_text(content))['xml'] |
| 537 | message_type = message['InfoType'].lower() |
| 538 | message_class = COMPONENT_MESSAGE_TYPES.get(message_type, ComponentUnknownMessage) |
| 539 | msg = message_class(message) |
| 540 | if msg.type == 'component_verify_ticket': |
| 541 | self.session.set(msg.type, msg.verify_ticket) |
| 542 | elif msg.type in ('authorized', 'updateauthorized'): |
| 543 | msg.query_auth_result = self.query_auth(msg.authorization_code) |
| 544 | return msg |
| 545 | |
| 546 | def cache_component_verify_ticket(self, msg, signature, timestamp, nonce): |
| 547 | """ |
nothing calls this directly
no test coverage detected