debug.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/Jinnrry/pmail/dto/parsemail"
  5. "github.com/Jinnrry/pmail/hooks/framework"
  6. "github.com/Jinnrry/pmail/models"
  7. "github.com/Jinnrry/pmail/utils/context"
  8. )
  9. type Debug struct {
  10. }
  11. func NewDebug() *Debug {
  12. return &Debug{}
  13. }
  14. func (d Debug) SendBefore(ctx *context.Context, email *parsemail.Email) {
  15. fmt.Printf("[debug SendBefore] %+v ", email)
  16. }
  17. func (d Debug) SendAfter(ctx *context.Context, email *parsemail.Email, err map[string]error) {
  18. fmt.Printf("[debug SendAfter] %+v ", email)
  19. }
  20. func (d Debug) ReceiveParseBefore(ctx *context.Context, email *[]byte) {
  21. fmt.Printf("[debug ReceiveParseBefore] %s ", *email)
  22. }
  23. func (d Debug) ReceiveParseAfter(ctx *context.Context, email *parsemail.Email) {
  24. fmt.Printf("[debug ReceiveParseAfter] %+v ", email)
  25. email.Status = 5
  26. }
  27. func (d Debug) ReceiveSaveAfter(ctx *context.Context, email *parsemail.Email, ue []*models.UserEmail) {
  28. fmt.Printf("[debug ReceiveSaveAfter] %+v %+v ", email, ue)
  29. }
  30. func (d Debug) GetName(ctx *context.Context) string {
  31. return "debug"
  32. }
  33. func (d Debug) SettingsHtml(ctx *context.Context, url string, requestData string) string {
  34. return ""
  35. }
  36. func main() {
  37. framework.CreatePlugin("debug_plugin", NewDebug()).Run()
  38. }