Skip to content

Commit

Permalink
Check for update capability before the action name
Browse files Browse the repository at this point in the history
Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>
  • Loading branch information
AndrewFerr and toger5 authored Jul 30, 2024
1 parent eba940b commit 9c2ac46
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions src/ClientWidgetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,39 +558,37 @@ export class ClientWidgetApi extends EventEmitter {
});
}

private handleUpdateDelayedEvent(request: IUpdateDelayedEventFromWidgetActionRequest) {
if (!request.data.delay_id) {
return this.transport.reply<IWidgetApiErrorResponseData>(request, {
error: {message: "Invalid request - missing delay_id"},
});
}
private handleUpdateDelayedEvent(request: IUpdateDelayedEventFromWidgetActionRequest) {

Check failure on line 561 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 0
if (!request.data.delay_id) {

Check failure on line 562 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 4
return this.transport.reply<IWidgetApiErrorResponseData>(request, {

Check failure on line 563 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 12 spaces but found 8
error: {message: "Invalid request - missing delay_id"},
});

Check failure on line 565 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 12 spaces but found 8
}

Check failure on line 566 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 4

switch (request.data.action) {
case UpdateDelayedEventAction.Cancel:
case UpdateDelayedEventAction.Restart:
case UpdateDelayedEventAction.Send:
break
default:
if (!this.hasCapability(MatrixCapabilities.MSC4157UpdateDelayedEvent)) {

Check failure on line 568 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 4
return this.transport.reply<IWidgetApiErrorResponseData>(request, {

Check failure on line 569 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 12 spaces but found 8
error: {message: "Missing capability"},
});

Check failure on line 571 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 12 spaces but found 8
}

Check failure on line 572 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 4

switch (request.data.action) {

Check failure on line 574 in src/ClientWidgetApi.ts

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 4
case UpdateDelayedEventAction.Cancel:
case UpdateDelayedEventAction.Restart:
case UpdateDelayedEventAction.Send:
this.driver.updateDelayedEvent(request.data.delay_id, request.data.action).then(() => {
return this.transport.reply<IWidgetApiAcknowledgeResponseData>(request, {});
}).catch(e => {
console.error("error updating delayed event: ", e);
return this.transport.reply<IWidgetApiErrorResponseData>(request, {
error: {message: "Invalid request - unsupported action"},
error: {message: "Error updating delayed event"},
});
}

if (!this.hasCapability(MatrixCapabilities.MSC4157UpdateDelayedEvent)) {
return this.transport.reply<IWidgetApiErrorResponseData>(request, {
error: {message: "Missing capability"},
});
}

this.driver.updateDelayedEvent(request.data.delay_id, request.data.action).then(() => {
return this.transport.reply<IWidgetApiAcknowledgeResponseData>(request, {});
}).catch(e => {
console.error("error updating delayed event: ", e);
default:
return this.transport.reply<IWidgetApiErrorResponseData>(request, {
error: {message: "Error updating delayed event"},
error: {message: "Invalid request - unsupported action"},
});
});
}
}

private async handleSendToDevice(request: ISendToDeviceFromWidgetActionRequest): Promise<void> {
if (!request.data.type) {
Expand Down

0 comments on commit 9c2ac46

Please sign in to comment.