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 JobPayloadSetDef struct {
} }
type JobPayloadFwdMsg struct { type JobPayloadMsgFwd struct {
ChatID64 int64 `json:"chat_id"` ChatID64 int64 `json:"chat_id"`
} }
type JobPayloadMsgDel struct {
ObjMsgID64 int64 `json:"obj_msg_id"`
}
type JobPayloadMsgRefresh struct { type JobPayloadMsgRefresh struct {
ObjID64 int64 `json:"obj_id"` ObjID64 int64 `json:"obj_id"`
} }

57
job.go
View File

@ -528,6 +528,44 @@ func jobMsgClient(j Job) {
return 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) { func jobBackupExport(j Job) {
var p JobPayloadBackupExport var p JobPayloadBackupExport
err := setJobStart(j.ID64) err := setJobStart(j.ID64)
@ -1360,25 +1398,6 @@ func jobGWithdraw(j Job) {
return 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) { func jobSetDef(j Job) {
var p JobPayloadSetDef var p JobPayloadSetDef
err := setJobStart(j.ID64) err := setJobStart(j.ID64)

View File

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