-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(call): Direct endpoint to check if call notification should be d…
…ismissed Signed-off-by: Joas Schilling <coding@schilljs.com>
- Loading branch information
1 parent
49f4e77
commit e295adb
Showing
9 changed files
with
538 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\Controller; | ||
|
||
use OCA\Talk\Service\ParticipantService; | ||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\Attribute\NoAdminRequired; | ||
use OCP\AppFramework\Http\Attribute\OpenAPI; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\OCSController; | ||
use OCP\IRequest; | ||
|
||
class CallCheckController extends OCSController { | ||
public function __construct( | ||
string $appName, | ||
IRequest $request, | ||
protected ParticipantService $participantService, | ||
protected ?string $userId, | ||
) { | ||
parent::__construct($appName, $request); | ||
} | ||
|
||
/** | ||
* Check if the current user is in a call or whether the notification should be dismissed | ||
* | ||
* @param string $token Conversation token to check | ||
* @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, null, array{}> | ||
* | ||
* 200: User has joined the call or there is no call any more, notification shall be dismissed | ||
* 403: Not logged in, invalid API call | ||
* 404: User didn't join the call, notification shall be kept | ||
*/ | ||
#[NoAdminRequired] | ||
#[OpenAPI(tags: ['call'])] | ||
public function isCurrentUserInCall(string $token): DataResponse { | ||
$status = Http::STATUS_OK; | ||
if ($this->userId === null) { | ||
$status = Http::STATUS_FORBIDDEN; | ||
} elseif ($this->participantService->isUserMissingFromCall($token, $this->userId)) { | ||
$status = Http::STATUS_NOT_FOUND; | ||
} | ||
return new DataResponse(null, $status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.