preserve existing fields dedupe logic
This commit is contained in:
@@ -24,6 +24,23 @@ from core.server import server
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _preserve_existing_fields(event_body: Dict[str, Any], existing_event: Dict[str, Any], field_mappings: Dict[str, Any]) -> None:
|
||||
"""
|
||||
Helper function to preserve existing event fields when not explicitly provided.
|
||||
|
||||
Args:
|
||||
event_body: The event body being built for the API call
|
||||
existing_event: The existing event data from the API
|
||||
field_mappings: Dict mapping field names to their new values (None means preserve existing)
|
||||
"""
|
||||
for field_name, new_value in field_mappings.items():
|
||||
if new_value is None and field_name in existing_event:
|
||||
event_body[field_name] = existing_event[field_name]
|
||||
logger.info(f"[modify_event] Preserving existing {field_name}")
|
||||
elif new_value is not None:
|
||||
event_body[field_name] = new_value
|
||||
|
||||
|
||||
# Helper function to ensure time strings for API calls are correctly formatted
|
||||
def _correct_time_format_for_api(
|
||||
time_str: Optional[str], param_name: str
|
||||
@@ -461,21 +478,12 @@ async def modify_event(
|
||||
)
|
||||
|
||||
# Preserve existing fields if not provided in the update
|
||||
if summary is None and 'summary' in existing_event:
|
||||
event_body["summary"] = existing_event["summary"]
|
||||
logger.info(f"[modify_event] Preserving existing summary: {existing_event['summary']}")
|
||||
|
||||
if description is None and 'description' in existing_event:
|
||||
event_body["description"] = existing_event["description"]
|
||||
logger.info("[modify_event] Preserving existing description")
|
||||
|
||||
if location is None and 'location' in existing_event:
|
||||
event_body["location"] = existing_event["location"]
|
||||
logger.info("[modify_event] Preserving existing location")
|
||||
|
||||
if attendees is None and 'attendees' in existing_event:
|
||||
event_body["attendees"] = existing_event["attendees"]
|
||||
logger.info("[modify_event] Preserving existing attendees")
|
||||
_preserve_existing_fields(event_body, existing_event, {
|
||||
"summary": summary,
|
||||
"description": description,
|
||||
"location": location,
|
||||
"attendees": attendees
|
||||
})
|
||||
|
||||
# Handle Google Meet conference data
|
||||
if add_google_meet is not None:
|
||||
|
||||
Reference in New Issue
Block a user