We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a05049b commit eb475e8Copy full SHA for eb475e8
1 file changed
pkg/handlers/event.go
@@ -170,6 +170,22 @@ func UpdateEventByID(c *gin.Context) {
170
return
171
}
172
173
+ // Validate patch fields for #36 visibility/status support
174
+ if err := event.ValidateUpdateFields(fields); err != nil {
175
+ c.JSON(http.StatusBadRequest, gin.H{
176
+ "error": err.Error(),
177
+ })
178
+ return
179
+ }
180
+
181
+ // Normalize public events: if visibility is being set to public in PATCH,
182
+ // clear minimum_visible_role automatically.
183
+ if visibilityRaw, ok := fields["visibility"]; ok {
184
+ if visibility, ok := visibilityRaw.(string); ok && strings.TrimSpace(visibility) == event.VisibilityPublic {
185
+ fields["minimum_visible_role"] = ""
186
187
188
189
err = db.UpdateEventByID(id, fields)
190
if err != nil {
191
if err == mongo.ErrNoDocuments {
0 commit comments