From d08c9e3083cdc4fde41b848d2206f241f8cd5170 Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 15 Oct 2025 23:36:00 -0700 Subject: [PATCH] fix(communities): preserve moderation fields on update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes data loss bug where moderationType and contentWarnings would be erased if not explicitly provided in update request. Previously, omitting these fields in an update request would remove them from the PDS record. Now follows the same pattern as other optional fields (displayName, description, etc.) by preserving existing values when not being updated. Impact: Prevents accidental erasure of moderation configuration when updating other community properties. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- internal/core/communities/service.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/core/communities/service.go b/internal/core/communities/service.go index 860fb96..7a36b2b 100644 --- a/internal/core/communities/service.go +++ b/internal/core/communities/service.go @@ -260,12 +260,18 @@ func (s *communityService) UpdateCommunity(ctx context.Context, req UpdateCommun } } + // Preserve moderation settings (even if empty) + // These fields are optional but should not be erased on update if req.ModerationType != nil { profile["moderationType"] = *req.ModerationType + } else if existing.ModerationType != "" { + profile["moderationType"] = existing.ModerationType } if len(req.ContentWarnings) > 0 { profile["contentWarnings"] = req.ContentWarnings + } else if len(existing.ContentWarnings) > 0 { + profile["contentWarnings"] = existing.ContentWarnings } // Preserve counts -- 2.51.2