Skip to content

Commit

Permalink
[SDAAP-49] fix(events) Exception being thrown on post to the events e…
Browse files Browse the repository at this point in the history
…ndpoint (#1742)
  • Loading branch information
marwoodandrew authored and MarkLark86 committed Dec 7, 2022
1 parent f5d9b1f commit 4646eff
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,23 @@ const modifyLocationForServer = (event) => {
null;
};

const removeFieldsStartingWith = (updates: {[key: string]: Array<any> | any}, prefix: string) => {
Object.keys(updates).forEach((field) => {
if (!Array.isArray(updates[field])) {
if (field.startsWith(prefix)) {
delete updates[field];
}
} else {
updates[field].forEach((arrayEntry) => {
Object.keys(arrayEntry).forEach((arrayEntryField) => {
if (arrayEntryField.startsWith(prefix)) {
delete arrayEntry[arrayEntryField];
}
});
});
}
});
};

const modifyForServer = (event, removeNullLinks = false) => {
modifyLocationForServer(event);
Expand All @@ -845,6 +862,9 @@ const modifyForServer = (event, removeNullLinks = false) => {
);
}

// clean up angular artifacts
removeFieldsStartingWith(event, '$$');

if (timeUtils.isEventInDifferentTimeZone(event)) {
if (get(event, 'dates.start') && moment.isMoment(event.dates.start)) {
event.dates.start = timeUtils.getDateInRemoteTimeZone(event.dates.start, event.dates.tz);
Expand Down

0 comments on commit 4646eff

Please sign in to comment.