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

Set the default timeout for requests to ExApps if none is set. #277

Merged
merged 5 commits into from
Jul 10, 2024
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: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.7.1 - 2024-07-xx]
## [2.8.0 - 2024-07-1x]

### Added

- New OCS API endpoint to setAppInitProgress. The old one is marked as deprecated. #319
- Added default timeout for requestToExApp function set to 3s. #277

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ to join us in shaping a more versatile, stable, and secure app landscape.
*Your insights, suggestions, and contributions are invaluable to us.*

]]></description>
<version>2.7.1</version>
<version>2.8.0</version>
<licence>agpl</licence>
<author mail="andrey18106x@gmail.com" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
<author mail="bigcat88@icloud.com" homepage="https://github.com/bigcat88">Alexander Piskun</author>
Expand Down
10 changes: 8 additions & 2 deletions lib/Service/AppAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ private function prepareRequestToExApp(
if (!empty($auth)) {
$options['auth'] = $auth;
}
if (!isset($options['timeout'])) {
$options['timeout'] = 3;
}

if ((!array_key_exists('multipart', $options)) && (count($params)) > 0) {
if ($method === 'GET') {
Expand Down Expand Up @@ -281,6 +284,9 @@ private function prepareRequestToExApp2(
if (!empty($auth)) {
$options['auth'] = $auth;
}
if (!isset($options['timeout'])) {
$options['timeout'] = 3;
}

if ((!array_key_exists('multipart', $options))) {
if (count($queryParams) > 0) {
Expand Down Expand Up @@ -658,7 +664,7 @@ public function getExAppDomain(ExApp $exApp): string {
*/
public function enableExApp(ExApp $exApp): bool {
if ($this->exAppService->enableExAppInternal($exApp)) {
$exAppEnabled = $this->requestToExApp($exApp, '/enabled?enabled=1', null, 'PUT');
$exAppEnabled = $this->requestToExApp($exApp, '/enabled?enabled=1', null, 'PUT', options: ['timeout' => 30]);
if ($exAppEnabled instanceof IResponse) {
$response = json_decode($exAppEnabled->getBody(), true);
if (empty($response['error'])) {
Expand All @@ -683,7 +689,7 @@ public function enableExApp(ExApp $exApp): bool {
*/
public function disableExApp(ExApp $exApp): bool {
$result = true;
$exAppDisabled = $this->requestToExApp($exApp, '/enabled?enabled=0', null, 'PUT');
$exAppDisabled = $this->requestToExApp($exApp, '/enabled?enabled=0', null, 'PUT', options: ['timeout' => 30]);
if ($exAppDisabled instanceof IResponse) {
$response = json_decode($exAppDisabled->getBody(), true);
if (isset($response['error']) && strlen($response['error']) !== 0) {
Expand Down
Loading