Files

187 lines
6.4 KiB
Go
Raw Permalink Normal View History

package wechat
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
import (
"context"
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
XmlUtils "encoding/xml"
"net/http"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/ArtisanCloud/PowerLibs/v3/http/helper"
"fmt"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/contract"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/messages"
models2 "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/models"
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/server/handlers/models"
)
// CallbackVerifyMessage
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
/**
* 微信服务器验证消息
* GET /api/wechat/callback/message
* https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
*/
func CallbackVerifyMessage(responseWriter http.ResponseWriter, request *http.Request) {
resp, err := setting.Wechat.SDK.Server.VerifyURL(request)
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
if err != nil {
log.Error("[X] Failed to verify message in Wechat Official Account callback")
responseWriter.WriteHeader(resp.StatusCode)
responseWriter.Write([]byte("Failed to verify message in Wechat Official Account callback (CallbackVerifyMessage): " + err.Error()))
return
}
// 给微信服务器回信
err = helper.HttpResponseSend(resp, responseWriter)
if err != nil {
log.Error("[X] Failed to reply back to Wechat Server (CallbackVerifyMessage): ", err.Error())
responseWriter.WriteHeader(500)
}
}
// CallbackNotifyEvents
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
/**
* 微信服务器通知事件
* POST /api/wechat/callback/message
* https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
*/
func CallbackNotifyEvents(responseWriter http.ResponseWriter, request *http.Request) {
resp, err := setting.Wechat.SDK.Server.Notify(request, func(event contract.EventInterface) interface{} {
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
switch event.GetMsgType() {
case models2.CALLBACK_MSG_TYPE_EVENT:
// "event" 类型消息处理
return callbackMsgEventHandler(request, event)
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
case models2.CALLBACK_MSG_TYPE_TEXT:
// "text" 类型消息处理
return callbackMsgTextHandler(event)
}
return messages.NewText("undefined event type: " + event.GetMsgType())
})
if err != nil {
log.Error("[X] Failed to get notified in Wechat Official Account callback (CallbackNotifyEvents): ", err.Error())
responseWriter.WriteHeader(resp.StatusCode)
responseWriter.Write([]byte("Failed to verify message in Wechat Official Account callback" + err.Error()))
}
// 给微信服务器回信
err = helper.HttpResponseSend(resp, responseWriter)
if err != nil {
log.Error("[X] Failed to reply back to Wechat Server (CallbackNotifyEvents): ", err.Error())
responseWriter.WriteHeader(500)
}
}
func callbackMsgEventHandler(request *http.Request, event contract.EventInterface) *messages.Text {
ctx := request.Context()
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
// 根据不同 event 分别处理
switch event.GetEvent() {
case models.CALLBACK_EVENT_SUBSCRIBE:
// event:subscribe 新用户关注公众号事件
return eventSubscribeHandler(event)
case models.CALLBACK_EVENT_SCAN:
// event:SCAN 老用户扫描二维码事件
return eventScanHandler(ctx, event)
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
case models.CALLBACK_EVENT_UNSUBSCRIBE:
// event:unsubscribe 掉粉事件处理
return eventUnsubscribeHandler(event)
}
return messages.NewText("undefined event type: " + event.GetChangeType())
}
// "text" 类型消息处理
func callbackMsgTextHandler(event contract.EventInterface) *messages.Text {
msg := models.MessageText{}
err := event.ReadMessage(&msg)
if err != nil {
log.Error("[X] Failed to handle callback Message TEXT: " + err.Error())
return messages.NewText("error: " + err.Error())
}
// fmt.Dump(msg)
log.Info("[+] Got message from " + msg.FromUserName + ": " + msg.Content)
return messages.NewText("您发送的消息已收到感谢您使用梦宁软件DevStar Studio \n\n" + " -- DevStar Studio" + "\n\n")
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
}
// event:subscribe 新用户关注公众号事件
func eventSubscribeHandler(event contract.EventInterface) *messages.Text {
msg := models.EventSubscribe{}
err := event.ReadMessage(&msg)
if err != nil {
log.Error("[X] Failed to handle callback Message event:subscribe: " + err.Error())
return messages.NewText("error: " + err.Error())
}
log.Info("[+] event:subscribe User Subscribed: " + msg.FromUserName + ", at Timestamp " + msg.CreateTime)
return messages.NewText("欢迎新用户! 请关注公众号后重新扫码!\n\n" + " -- DevStar Studio" + "\n\n")
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
}
// event:SCAN 类型消息,已关注公众号的老用户扫码
func eventScanHandler(ctx context.Context, event contract.EventInterface) *messages.Text {
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
msg := models.EventScanCodePush{}
err := event.ReadMessage(&msg)
if err != nil {
log.Error("[X] Failed to handle callback event SCAN: " + err.Error())
return messages.NewText("error: " + err.Error())
}
var qrScanResponseDigest struct {
FromUserName string `xml:"FromUserName"`
Ticket string `xml:"Ticket"`
SceneStr string `xml:"EventKey"`
}
err = XmlUtils.Unmarshal([]byte(event.GetContent()), &qrScanResponseDigest)
if err != nil {
log.Error("[X] Failed to handle callback event SCAN: " + err.Error())
return messages.NewText("error: " + err.Error())
}
// 准备扫码状态VO对象
qrStatus := WechatTempQRStatus{
SceneStr: qrScanResponseDigest.SceneStr,
IsScanned: true,
OpenId: qrScanResponseDigest.FromUserName,
}
log.Info("扫码成功:\n" +
fmt.Sprintf(" Ticket: %s\n", qrScanResponseDigest.Ticket) +
fmt.Sprintf(" SceneStr: %s\n", qrStatus.SceneStr))
qrStatus.IsBinded = false
qrStatus.OpenId = qrScanResponseDigest.FromUserName
qrVOJsonString, err := qrStatus.Marshal2JSONString()
if err == nil {
SetWechatQrTicketWithTTL(
qrScanResponseDigest.Ticket,
qrVOJsonString,
setting.Wechat.TempQrExpireSeconds)
}
loginSuccessInfo := "您正在微信扫码登录" + fmt.Sprintf(" %s ", msg.EventKey) +
"\n\n" + " -- DevStar Studio" + "\n\n" +
"如非本人操作,请尽快重新绑定微信!"
Updated Wechat QR Login Prototype: both Frontend and Backend ------ Squashed commit of the following: commit b6108854f87c72832b4ccf65f2b02cfa79818d28 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 11:43:27 2024 +0000 Wechat QR scan prototype done: frontend and backend commit ace0cbbc75c5441c77121463a658115c59292727 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 07:53:47 2024 +0000 Updated ICP license for https://*.devstar.cn commit eab20f110c1f89447ad7bea9dd1f325a99e1f196 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Tue Jul 30 04:14:11 2024 +0000 updated wechat callback and changed sceneStr with higher entropy commit dd04b3b21b613d470d0ae27edbcead9aa2958861 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 14:33:04 2024 +0000 WeChat callback interfaces commit 320ba2225a420feb58c3668d4afca96fcbfe5c79 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Mon Jul 29 13:16:16 2024 +0000 updated env settings commit 2ed4e3e307f03b7a7a0dd626cfcf7e9b000e2ebe Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 11:48:00 2024 +0000 resolved WARN NoEmptyContinuation (grammar mistakes), and removed trivial unit test for hCAPTCHA commit 690157811bf516d8ca2c684f9aec50195ee2707d Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:21:39 2024 +0000 fix: checkout the corresponding branch(master or dev) commit 046ff63e42ab4ab3e817350c530165d6ea5d0309 Author: DAI Mingchen <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 10:01:24 2024 +0000 test new CI pipeline workflow in the org repo, with a bunch of ENV vars commit faf7f51d859a88932c53f2f66ede66817c3c1fcb Author: 戴明辰 <daimingchen@mail.ustc.edu.cn> Date: Thu Jul 25 07:59:31 2024 +0000 !1 DevStar Studio 界面原型 + CI流水线测试通过 * finalize this PoC repo, and migrate to the main repo (as a dev branch) * bugFix: nullptr dereference @ routers/web/auth/wechat_utils.go * bugFix: CAPTCHA needs manual reloading * Updated UI * Changed logo and favicon * Made WeChat QR optional (will not cause HTTP 500 Internal Error), and … * Added Unit Test in CI workflow, and removed redundant tests in dev container * Compliance with open source licensing requirements * Fix workflow: only exec 'docker rm' if there are dangling volumes * Removed Magic values about: Docker registry(URL, username), k8s(nanesp… * fix mistakes: git checkout branch should be master rather than the sta… * Updated UI layouts and build scripts * Updated copyright info and ICP License ID at page footer * Updated ICP License ID at page footer * Updated code ownership: web footer, logo and favicon * Updated Internationalization(i18n): removed languages other than CN an…
2024-07-30 12:52:55 +00:00
return messages.NewText(loginSuccessInfo)
}
// event:unsubscribe 掉粉事件处理
func eventUnsubscribeHandler(event contract.EventInterface) *messages.Text {
msg := models.EventUnSubscribe{}
err := event.ReadMessage(&msg)
if err != nil {
log.Error("[X] Failed to handle callback Message event:unsubscribe: " + err.Error())
return messages.NewText("error: " + err.Error())
}
log.Info("[+] event:unsubscribe User Unsubscribed: " + msg.ToUserName + ", at Timestamp " + msg.CreateTime)
return messages.NewText("user unsubscribed: " + msg.FromUserName)
}