Beispiel #1
0
        public string UserMessageHandler(string appid, [FromQuery] MessageRequestQuery query, [FromBody] MessageRequsetBody body)
        {
            if (_weSdk.CheckMsgSign(query, body.Encrypt))
            {
                var data = new UserMessageRequsetXml(_weSdk.DecryptMsg(body.Encrypt))
                {
                    AppId = appid
                };
                if (data.MsgType == "event")
                {
                    if (data.Event == "TEMPLATESENDJOBFINISH")
                    {
                        var messageStatus = new MessageStatus(_redis);
                        var messageId     = messageStatus.GetTemplateMessageId(data.MsgId);
                        if (messageId != null)
                        {
                            messageStatus.SetMessageId(messageId);
                            switch (data.Status)
                            {
                            case TemplateMessageStatus.Success:
                                messageStatus.Success(data.FromUserName);
                                break;

                            case TemplateMessageStatus.UserBlock:
                                messageStatus.UserBlock(data.FromUserName);
                                break;

                            case TemplateMessageStatus.SystemFailed:
                                messageStatus.SystemFailed(data.FromUserName);
                                break;
                            }
                        }
                    }
                    else
                    {
                        _eventQueue.Enqueue(data);
                        if (data.Event == "weapp_audit_success")
                        {
                            //TODO:: For Audit Success Auto Process;
                        }
                    }
                }
                else
                {
                    _messageQueue.Enqueue(data);
                }
            }
            return("success");
        }