test unknown msg

This commit is contained in:
shoopea 2020-02-11 10:06:04 +08:00
parent e9042797d9
commit 38c5200d96
3 changed files with 26 additions and 0 deletions

View File

@ -669,6 +669,11 @@
"name": "Set User Config Pillage OFF",
"obj_type": "msg"
},
{
"intl_id": "msg_unknown_action",
"name": "Set Unknown Action",
"obj_type": "msg"
},
{
"intl_id": "job_pillage",
"name": "Pillage job",

View File

@ -1894,5 +1894,13 @@
"msg_type": "msg_shop_main_ack",
"chat_id": 0,
"user_id": 0
},
{
"prio": 5000,
"descn": "Message unknown action",
"rule": "^¯\\\\\\_\\(ツ\\)_\\/¯$",
"msg_type": "msg_unknown_action",
"chat_id": 0,
"user_id": 0
}
]

13
job.go
View File

@ -2314,6 +2314,18 @@ func jobShopsSlave(j Job) {
logOnError(err, "jobShopsSlave : getMsgParsingRule")
switch id {
case cacheObjSubType[`msg_unknown_action`]:
muxObjJob.Lock()
b2 := getJobPayloadUnsafe(p.JobCallbackID64)
var p2 JobPayloadShops
err = json.Unmarshal(b2, &p2)
p2.Msgs = append(p2.Msgs, *m)
err = setJobPayloadJSONUnsafe(p.JobCallbackID64, p2)
logOnError(err, "jobShopsSlave : setJobPayloadJSONUnsafe")
muxObjJob.Unlock()
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) // reschedule so that it gets picked up by shop main ack callback
return
case cacheObjSubType[`msg_shop_main_req`]:
muxObjJob.Lock()
b2 := getJobPayloadUnsafe(p.JobCallbackID64)
@ -2355,6 +2367,7 @@ func jobShopsSlave(j Job) {
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) // reschedule so that it gets picked up by shop main ack callback
setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_shop_main_req`])
setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_shop_main_ack`])
setJobCallback(j.ID64, j.UserID64, cacheObjSubType[`msg_unknown_action`])
clientSendCWMsgDelay(j.UserID64, fmt.Sprintf("/ws_%s", p.Shops[0]), 4*time.Second)
return
}