github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/web/middlewares/warnings.go (about) 1 package middlewares 2 3 import ( 4 "net/http" 5 6 "github.com/cozy/cozy-stack/model/instance" 7 "github.com/cozy/cozy-stack/pkg/jsonapi" 8 ) 9 10 // ListWarnings returns a list of possible warnings associated with the 11 // instance. 12 func ListWarnings(i *instance.Instance) (warnings []*jsonapi.Error) { 13 if err := i.MovedError(); err != nil { 14 warnings = append(warnings, err) 15 } 16 notSigned, deadline := i.CheckTOSNotSignedAndDeadline() 17 if notSigned && deadline >= instance.TOSWarning { 18 tosLink, _ := i.ManagerURL(instance.ManagerTOSURL) 19 warnings = append(warnings, &jsonapi.Error{ 20 Status: http.StatusPaymentRequired, 21 Title: "TOS Updated", 22 Code: "tos-updated", 23 Detail: i.Translate("Terms of services have been updated"), 24 Links: &jsonapi.LinksList{Self: tosLink}, 25 }) 26 } 27 return 28 }