Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where Graph events were returning 400 on update #524

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Unreleased
* Fix issue where Graph events were returning 400 on update

### 6.11.0 / 2023-11-28
* Add support for logging
* Nullify replyToMessageId is an empty string
Expand Down
30 changes: 27 additions & 3 deletions src/models/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ export default class Event extends RestfulModel {
organizerEmail?: string;
organizerName?: string;
hideParticipants?: boolean;
visibility?: string;
customerEventId?: string;
private _visibility?: string;
private visibilityIsDirty = false;
static collectionName = 'events';
static attributes: Record<string, Attribute> = {
...RestfulModel.attributes,
Expand Down Expand Up @@ -220,7 +221,8 @@ export default class Event extends RestfulModel {
jsonKey: 'hide_participants',
}),
visibility: Attributes.String({
modelKey: 'visibility',
modelKey: '_visibility',
jsonKey: 'visibility',
}),
customerEventId: Attributes.String({
modelKey: 'customerEventId',
Expand All @@ -231,6 +233,7 @@ export default class Event extends RestfulModel {
constructor(connection: NylasConnection, props?: EventProperties) {
super(connection, props);
this.initAttributes(props);
this.visibilityIsDirty = false;
}

get start(): string | number | undefined {
Expand Down Expand Up @@ -307,6 +310,18 @@ export default class Event extends RestfulModel {
}
}

get visibility(): string | undefined {
return this._visibility;
}

set visibility(val: string | undefined) {
if (val !== this._visibility) {
this.visibilityIsDirty = true;
}

this._visibility = val;
}

deleteRequestQueryString(
params: Record<string, unknown> = {}
): Record<string, unknown> {
Expand All @@ -333,7 +348,10 @@ export default class Event extends RestfulModel {
participant => delete participant.status
);
}
if (this.visibility !== undefined && this.visibility === '') {
if (
(this.visibility !== undefined && this.visibility === '') ||
!this.visibilityIsDirty
) {
delete json.visibility;
}

Expand Down Expand Up @@ -402,6 +420,12 @@ export default class Event extends RestfulModel {
});
}

fromJSON(json: Record<string, unknown>): this {
const model = super.fromJSON(json);
model.visibilityIsDirty = false;
return model;
}

private validate(): void {
if (
this.conferencing &&
Expand Down
Loading