fix: IMAP-Konto bearbeiten + Löschen auch bei sync_running

- Store: UpdateCredentials() — Zugangsdaten + Passwort neu verschlüsseln,
  setzt status='idle', error_msg='', sync_running=false zurück
- Handler: PATCH /api/imap/{id} unterstützt nun Credential-Update
  (name/host/username vorhanden = Credential-Update, sonst sync_interval)
- Frontend: "Bearbeiten"-Button öffnet Edit-Dialog mit allen Feldern;
  Passwort-Feld leer = unverändertes Passwort
- Frontend: Löschen-Button nicht mehr durch sync_running blockiert
  (nur noch bei status=running gesperrt)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sysops
2026-03-20 00:49:37 +01:00
parent 4a4136e4a6
commit c59cad92be
4 changed files with 184 additions and 3 deletions
+27
View File
@@ -282,6 +282,33 @@ func (s *Store) UpdateDone(ctx context.Context, id int64, count int) error {
return nil
}
// UpdateCredentials updates the connection details and optionally the password
// of an IMAP account. Pass an empty password to leave it unchanged.
func (s *Store) UpdateCredentials(ctx context.Context, id int64, acc Account, password string) error {
if password != "" {
enc, err := encryptPassword(password, s.encKey)
if err != nil {
return fmt.Errorf("imap store: encrypt password: %w", err)
}
_, err = s.pool.Exec(ctx,
`UPDATE imap_accounts SET name=$1, host=$2, port=$3, tls=$4, username=$5, password_enc=$6,
status='idle', error_msg='', sync_running=false WHERE id=$7`,
acc.Name, acc.Host, acc.Port, acc.TLS, acc.Username, enc, id)
if err != nil {
return fmt.Errorf("imap store: update credentials: %w", err)
}
} else {
_, err := s.pool.Exec(ctx,
`UPDATE imap_accounts SET name=$1, host=$2, port=$3, tls=$4, username=$5,
status='idle', error_msg='', sync_running=false WHERE id=$6`,
acc.Name, acc.Host, acc.Port, acc.TLS, acc.Username, id)
if err != nil {
return fmt.Errorf("imap store: update credentials (no pw): %w", err)
}
}
return nil
}
// UpdateSyncInterval sets the automatic sync interval for an account.
// intervalMin == 0 disables automatic sync.
func (s *Store) UpdateSyncInterval(ctx context.Context, id int64, intervalMin int) error {