示例#1
0
        public string PlatformMessageHandler([FromQuery] MessageRequestQuery query, [FromBody] MessageRequsetBody body)
        {
            if (_weSdk.CheckMsgSign(query, body.Encrypt))
            {
                var data = new PlatformMessageRequestXml(_weSdk.DecryptMsg(body.Encrypt));
                switch (data.InfoType)
                {
                case "updateauthorized":
                    BackgroundJob.Enqueue <UpdateAuth>(x => x.Run(data.AuthorizationCode, null));
                    break;

                case "unauthorized":
                    BackgroundJob.Enqueue <ClearAuth>(x => x.Run(data.AuthorizerAppId, null));
                    break;

                case "authorized":
                    BackgroundJob.Enqueue <UpdateAuth>(x => x.Run(data.AuthorizationCode, null));
                    break;

                case "component_verify_ticket":
                    BackgroundJob.Enqueue <UpdateVerifyTicket>(x => x.Run(data.ComponentVerifyTicket, null));
                    break;
                }
            }
            return("success");
        }
示例#2
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");
        }