A community based topic aggregation platform built on atproto

fix(communities): preserve moderation fields on update

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 <noreply@anthropic.com>

Changed files
+6
internal
core
communities
+6
internal/core/communities/service.go
···
}
}
if req.ModerationType != nil {
profile["moderationType"] = *req.ModerationType
}
if len(req.ContentWarnings) > 0 {
profile["contentWarnings"] = req.ContentWarnings
}
// Preserve counts
···
}
}
+
// 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