Skip to content

Commit

Permalink
Merge pull request #10186 from nextcloud/feature/openapi
Browse files Browse the repository at this point in the history
Add OpenAPI
  • Loading branch information
nickvergessen authored Oct 6, 2023
2 parents 19a7042 + a8a21d5 commit d4b5c75
Show file tree
Hide file tree
Showing 57 changed files with 18,196 additions and 180 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: OpenAPI

on:
pull_request:
push:
branches:
- master
- stable*

permissions:
contents: read

concurrency:
group: openapi-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
openapi:
runs-on: ubuntu-latest

if: ${{ github.repository_owner != 'nextcloud-gmbh' }}

steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Set up php
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
with:
php-version: '8.2'
extensions: xml
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up dependencies
run: composer i

- name: Regenerate OpenAPI
run: composer run openapi

- name: Check openapi.json changes
run: |
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi.json, see the section \"Show changes on failure\" for details' && exit 1)"
- name: Show changes on failure
if: failure()
run: |
git status
git --no-pager diff
exit 1 # make it red to grab attention
2 changes: 1 addition & 1 deletion appinfo/routes/routesAvatarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '^[a-z0-9]{4,30}$',
];

Expand Down
6 changes: 3 additions & 3 deletions appinfo/routes/routesBotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

$requirementsWithMessageId = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
'messageId' => '[0-9]+',
];

$requirementsWithBotId = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
'botId' => '[0-9]+',
];
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesBreakoutRoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesCallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v4',
'apiVersion' => '(v4)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesCertificateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes/routesChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

$requirementsWithMessageId = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
'messageId' => '[0-9]+',
];
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesFederationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes/routesFilesIntegrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
*/

$requirementsFile = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'fileId' => '.+',
];
$requirementsShare = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'shareToken' => '.+',
];

Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesGuestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesHostedSignalingServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesMatterbridgeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesMatterbridgeSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes/routesPollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

$requirementsWithPollId = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
'pollId' => '\d+',
];
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesPublicShareAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesReactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
'messageId' => '[0-9]+',
];
Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesRecordingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes/routesRoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
*/

$requirements = [
'apiVersion' => 'v4',
'apiVersion' => '(v4)',
];

$requirementsWithToken = [
'apiVersion' => 'v4',
'apiVersion' => '(v4)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
2 changes: 1 addition & 1 deletion appinfo/routes/routesSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

$requirements = [
'apiVersion' => 'v1',
'apiVersion' => '(v1)',
];

return [
Expand Down
4 changes: 2 additions & 2 deletions appinfo/routes/routesSignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
*/

$requirements = [
'apiVersion' => 'v3',
'apiVersion' => '(v3)',
];


$requirementsWithToken = [
'apiVersion' => 'v3',
'apiVersion' => '(v3)',
'token' => '[a-z0-9]{4,30}',
];

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -not -path './lib/Vendor/*' -not -path './build/*' -not -path './tests/integration/vendor/*' -print0 | xargs -0 -n1 php -l",
"openapi": "generate-spec",
"psalm": "psalm --threads=1",
"psalm:dev": "psalm --no-cache --threads=$(nproc)",
"psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
Expand Down
9 changes: 9 additions & 0 deletions lib/Chat/ReactionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@
use OCA\Talk\Exceptions\ReactionNotSupportedException;
use OCA\Talk\Exceptions\ReactionOutOfContextException;
use OCA\Talk\Participant;
use OCA\Talk\ResponseDefinitions;
use OCA\Talk\Room;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
use OCP\Comments\NotFoundException;
use OCP\IL10N;
use OCP\PreConditionNotMetException;

/**
* @psalm-import-type TalkReaction from ResponseDefinitions
*/
class ReactionManager {

public function __construct(
Expand Down Expand Up @@ -138,6 +143,10 @@ public function deleteReactionMessage(Room $chat, string $actorType, string $act
return $comment;
}

/**
* @return array<string, TalkReaction[]>
* @throws PreConditionNotMetException
*/
public function retrieveReactionMessages(Room $chat, Participant $participant, int $messageId, ?string $reaction = null): array {
if ($reaction) {
$comments = $this->commentsManager->retrieveAllReactionsWithSpecificReaction($messageId, $reaction);
Expand Down
Loading

0 comments on commit d4b5c75

Please sign in to comment.