| 465 | } |
| 466 | |
| 467 | func (t *HookTask) AfterSet(colName string, _ xorm.Cell) { |
| 468 | var err error |
| 469 | switch colName { |
| 470 | case "delivered": |
| 471 | t.DeliveredString = time.Unix(0, t.Delivered).Format("2006-01-02 15:04:05 MST") |
| 472 | |
| 473 | case "request_content": |
| 474 | if t.RequestContent == "" { |
| 475 | return |
| 476 | } |
| 477 | |
| 478 | t.RequestInfo = &HookRequest{} |
| 479 | if err = jsoniter.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil { |
| 480 | log.Error("Unmarshal[%d]: %v", t.ID, err) |
| 481 | } |
| 482 | |
| 483 | case "response_content": |
| 484 | if t.ResponseContent == "" { |
| 485 | return |
| 486 | } |
| 487 | |
| 488 | t.ResponseInfo = &HookResponse{} |
| 489 | if err = jsoniter.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil { |
| 490 | log.Error("Unmarshal [%d]: %v", t.ID, err) |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | func (t *HookTask) ToJSON(v any) string { |
| 496 | p, err := jsoniter.Marshal(v) |