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

Function imapAcctAppendlimit

internal/cli/ctl/appendlimit.go:41–79  ·  view source on GitHub ↗
(be module.Storage, ctx *cli.Context)

Source from the content-addressed store, hash-verified

39}
40
41func imapAcctAppendlimit(be module.Storage, ctx *cli.Context) error {
42 username := ctx.Args().First()
43 if username == "" {
44 return cli.Exit("Error: USERNAME is required", 2)
45 }
46
47 u, err := be.GetIMAPAcct(username)
48 if err != nil {
49 return err
50 }
51 userAL, ok := u.(AppendLimitUser)
52 if !ok {
53 return cli.Exit("Error: module.Storage does not support per-user append limit", 2)
54 }
55
56 if ctx.IsSet("value") {
57 val := ctx.Int("value")
58
59 var err error
60 if val == -1 {
61 err = userAL.SetMessageLimit(nil)
62 } else {
63 val32 := uint32(val)
64 err = userAL.SetMessageLimit(&val32)
65 }
66 if err != nil {
67 return err
68 }
69 } else {
70 lim := userAL.CreateMessageLimit()
71 if lim == nil {
72 fmt.Println("No limit")
73 } else {
74 fmt.Println(*lim)
75 }
76 }
77
78 return nil
79}

Callers 1

initFunction · 0.85

Calls 7

ArgsMethod · 0.80
IsSetMethod · 0.80
IntMethod · 0.80
SetMessageLimitMethod · 0.80
CreateMessageLimitMethod · 0.80
PrintlnMethod · 0.80
GetIMAPAcctMethod · 0.65

Tested by

no test coverage detected