Phase 11, part 3: approvals for what agents send out
Agents can now ask to publish or schedule a post, send an email, add someone to a mailing list, or apply an SEO change. Each waits on the Approvals page (with a count in the sidebar) for an admin or a member with edit on its module, who can edit it first, approve or refuse it, and let the agent take that class of action on its own with a cap per day. A rotation after a leak revokes the old keys and withdraws everything allowed. All of it is in the audit log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,6 +118,15 @@ func (s *Server) listmonkTest(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// addToList adds a person to a mailing list.
|
||||
func (s *Server) addToList(r *http.Request, id int64) error {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), time.Minute)
|
||||
defer cancel()
|
||||
return s.addToListID(ctx, id, r.PostFormValue("list"), r.PostFormValue("agreed") == "on")
|
||||
}
|
||||
|
||||
// addToListID adds a person to a mailing list, by the list's ID. confirmed
|
||||
// says they agreed to receive it; without that, only a double opt-in list
|
||||
// takes them (it asks them first).
|
||||
func (s *Server) addToListID(ctx context.Context, id int64, listID string, confirmed bool) error {
|
||||
c := s.listmonk()
|
||||
if c == nil {
|
||||
return errors.New("set up Listmonk under Settings → Email first")
|
||||
@@ -138,22 +147,19 @@ func (s *Server) addToList(r *http.Request, id int64) error {
|
||||
} else if sup {
|
||||
return errors.New(p.Email + " is on your suppression list, so it can't go on a mailing list")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), time.Minute)
|
||||
defer cancel()
|
||||
lists, err := s.mailingLists(ctx, false)
|
||||
if err != nil && len(lists) == 0 {
|
||||
return err
|
||||
}
|
||||
var list *listmonk.List
|
||||
for i := range lists {
|
||||
if fmt.Sprint(lists[i].ID) == r.PostFormValue("list") {
|
||||
if fmt.Sprint(lists[i].ID) == listID {
|
||||
list = &lists[i]
|
||||
}
|
||||
}
|
||||
if list == nil {
|
||||
return errors.New("choose a mailing list")
|
||||
}
|
||||
confirmed := r.PostFormValue("agreed") == "on"
|
||||
if !confirmed && !list.Double() {
|
||||
return errors.New(list.Name + " sends its mail without asking first: add someone there only once they've agreed to receive it, or choose a double opt-in list")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user