This commit is contained in:
shoopea 2020-01-26 22:19:15 +08:00
parent 8b23348229
commit f7ac5ea997

38
job.go
View File

@ -1968,17 +1968,37 @@ func jobGetVault(j Job) {
p.CleanupMsg = append(p.CleanupMsg, *m) p.CleanupMsg = append(p.CleanupMsg, *m)
case cacheObjSubType[`msg_gstock_oth_req`]: case cacheObjSubType[`msg_gstock_oth_req`]:
fallthrough log.Printf("jobGetVault[%d] : Receiving other.\n", j.ID64)
p.CleanupMsg = append(p.CleanupMsg, *m)
setJobPayloadJSON(j.ID64, p)
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
return
case cacheObjSubType[`msg_gstock_res_req`]: case cacheObjSubType[`msg_gstock_res_req`]:
fallthrough log.Printf("jobGetVault[%d] : Receiving res.\n", j.ID64)
p.CleanupMsg = append(p.CleanupMsg, *m)
setJobPayloadJSON(j.ID64, p)
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
return
case cacheObjSubType[`msg_gstock_alch_req`]: case cacheObjSubType[`msg_gstock_alch_req`]:
fallthrough log.Printf("jobGetVault[%d] : Receiving alch.\n", j.ID64)
p.CleanupMsg = append(p.CleanupMsg, *m)
setJobPayloadJSON(j.ID64, p)
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
return
case cacheObjSubType[`msg_gstock_misc_req`]: case cacheObjSubType[`msg_gstock_misc_req`]:
fallthrough log.Printf("jobGetVault[%d] : Receiving misc.\n", j.ID64)
p.CleanupMsg = append(p.CleanupMsg, *m)
setJobPayloadJSON(j.ID64, p)
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
return
case cacheObjSubType[`msg_gstock_rec_req`]: case cacheObjSubType[`msg_gstock_rec_req`]:
fallthrough log.Printf("jobGetVault[%d] : Receiving recipe.\n", j.ID64)
p.CleanupMsg = append(p.CleanupMsg, *m)
setJobPayloadJSON(j.ID64, p)
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
return
case cacheObjSubType[`msg_gstock_part_req`]: case cacheObjSubType[`msg_gstock_part_req`]:
log.Printf("jobGetVault[%d] : Got own request.\n", j.ID64) log.Printf("jobGetVault[%d] : Receiving part.\n", j.ID64)
p.CleanupMsg = append(p.CleanupMsg, *m) p.CleanupMsg = append(p.CleanupMsg, *m)
setJobPayloadJSON(j.ID64, p) setJobPayloadJSON(j.ID64, p)
rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC()) rescheduleJob(j.ID64, 0, time.Unix(maxUnixTimestamp, 0).UTC())
@ -2051,17 +2071,23 @@ func jobGetVault(j Job) {
return return
} }
log.Printf("jobGetVault[%d] : Cleaning up.\n", j.ID64)
/* clean up the messages */ /* clean up the messages */
for _, d := range p.CleanupMsg { for _, d := range p.CleanupMsg {
clientDelTGMsg(j.UserID64, d.ID64, d.ChatID64) clientDelTGMsg(j.UserID64, d.ID64, d.ChatID64)
} }
log.Printf("jobGetVault[%d] : Rescheduling callback.\n", j.ID64)
/* wake up the callback */ /* wake up the callback */
err = rescheduleJob(p.JobCallbackID64, 0, time.Now().UTC()) err = rescheduleJob(p.JobCallbackID64, 0, time.Now().UTC())
logOnError(err, "jobGetVault : rescheduleJob") logOnError(err, "jobGetVault : rescheduleJob")
/* no more req to send, all ack came through, we can finish the job */ /* no more req to send, all ack came through, we can finish the job */
log.Printf("jobGetVault[%d] : All done.\n", j.ID64)
err = setJobDone(j.ID64) err = setJobDone(j.ID64)
logOnError(err, "jobGetVault : setJobDone") logOnError(err, "jobGetVault : setJobDone")