MCPcopy Index your code
hub / github.com/foxcpp/maddy / msgsAdd

Function msgsAdd

internal/cli/ctl/imap.go:540–587  ·  view source on GitHub ↗
(be module.Storage, ctx *cli.Context)

Source from the content-addressed store, hash-verified

538}
539
540func msgsAdd(be module.Storage, ctx *cli.Context) error {
541 username := ctx.Args().First()
542 if username == "" {
543 return cli.Exit("Error: USERNAME is required", 2)
544 }
545 name := ctx.Args().Get(1)
546 if name == "" {
547 return cli.Exit("Error: MAILBOX is required", 2)
548 }
549
550 u, err := be.GetIMAPAcct(username)
551 if err != nil {
552 return err
553 }
554
555 flags := ctx.StringSlice("flag")
556 if flags == nil {
557 flags = []string{}
558 }
559
560 date := time.Now()
561 if ctx.IsSet("date") {
562 date = *ctx.Timestamp("date")
563 }
564
565 buf := bytes.Buffer{}
566 if _, err := io.Copy(&buf, os.Stdin); err != nil {
567 return err
568 }
569
570 if buf.Len() == 0 {
571 return cli.Exit("Error: Empty message, refusing to continue", 2)
572 }
573
574 status, err := u.Status(name, []imap.StatusItem{imap.StatusUidNext})
575 if err != nil {
576 return err
577 }
578
579 if err := u.CreateMessage(name, flags, date, &buf, nil); err != nil {
580 return err
581 }
582
583 // TODO: Use APPENDUID
584 fmt.Println(status.UidNext)
585
586 return nil
587}
588
589func msgsRemove(be module.Storage, ctx *cli.Context) error {
590 username := ctx.Args().First()

Callers 1

initFunction · 0.85

Calls 7

LenMethod · 0.95
ArgsMethod · 0.80
IsSetMethod · 0.80
CopyMethod · 0.80
PrintlnMethod · 0.80
GetIMAPAcctMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected