update jobs

This commit is contained in:
shoopea 2020-01-07 18:32:20 +08:00
parent 9cd628ecf3
commit eb97e9c337
3 changed files with 47 additions and 22 deletions

6
def.go
View File

@ -334,10 +334,14 @@ type JobPayloadGetHammerTime struct {
type JobPayloadSetDef struct {
}
type JobPayloadFwdMsg struct {
type JobPayloadMsgFwd struct {
ChatID64 int64 `json:"chat_id"`
}
type JobPayloadMsgDel struct {
ObjMsgID64 int64 `json:"obj_msg_id"`
}
type JobPayloadMsgRefresh struct {
ObjID64 int64 `json:"obj_id"`
}

57
job.go
View File

@ -528,6 +528,44 @@ func jobMsgClient(j Job) {
return
}
func jobMsgFwd(j Job) {
var p JobPayloadMsgFwd
err := setJobStart(j.ID64)
logOnError(err, "jobFwdMsg : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobFwdMsg : Unmarshal payload")
msg, err := getObjMsg(j.Trigger)
logOnError(err, "jobFwdMsg : getObjMsg msg")
clientFwdCWMsg(j.UserID64, msg.ID64, msg.ChatID64, p.ChatID64)
err = setJobDone(j.ID64)
logOnError(err, "jobFwdMsg : setJobDone")
return
}
func jobMsgDel(j Job) {
var p JobPayloadMsgDel
err := setJobStart(j.ID64)
logOnError(err, "jobMsgDel : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobMsgDel : Unmarshal payload")
msg, err := getObjMsg(j.Trigger)
logOnError(err, "jobMsgDel : getObjMsg msg")
clientFwdCWMsg(j.UserID64, msg.ID64, msg.ChatID64, p.ChatID64)
err = setJobDone(j.ID64)
logOnError(err, "jobMsgDel : setJobDone")
return
}
func jobBackupExport(j Job) {
var p JobPayloadBackupExport
err := setJobStart(j.ID64)
@ -1360,25 +1398,6 @@ func jobGWithdraw(j Job) {
return
}
func jobFwdMsg(j Job) {
var p JobPayloadFwdMsg
err := setJobStart(j.ID64)
logOnError(err, "jobFwdMsg : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobFwdMsg : Unmarshal payload")
msg, err := getObjMsg(j.Trigger)
logOnError(err, "jobFwdMsg : getObjMsg msg")
clientFwdCWMsg(j.UserID64, msg.ID64, msg.ChatID64, p.ChatID64)
err = setJobDone(j.ID64)
logOnError(err, "jobFwdMsg : setJobDone")
return
}
func jobSetDef(j Job) {
var p JobPayloadSetDef
err := setJobStart(j.ID64)

View File

@ -559,6 +559,10 @@ func JobWorker(id int, jobs <-chan Job) {
jobMsgClient(j)
case cacheObjSubType[`job_msg_refresh`]:
jobMsgRefresh(j)
case cacheObjSubType[`job_msg_fwd`]:
jobMsgFwd(j)
case cacheObjSubType[`job_msg_del`]:
jobMsgDelete(j)
case cacheObjSubType[`job_backup_export`]:
jobBackupExport(j)
case cacheObjSubType[`job_backup_import`]:
@ -575,8 +579,6 @@ func JobWorker(id int, jobs <-chan Job) {
jobVaultUserStatus(j)
case cacheObjSubType[`job_vault_item_status`]:
jobVaultItemStatus(j)
case cacheObjSubType[`job_msg_fwd`]:
jobFwdMsg(j)
case cacheObjSubType[`job_set_def`]:
jobSetDef(j)
case cacheObjSubType[`job_get_hammer_time`]: