Skip to content
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
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions lib/Controller/APIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

/**
* @psalm-import-type NotificationsRichObjectParameter from ResponseDefinitions
* @psalm-import-type NotificationsRichObjectParameters from ResponseDefinitions
*/
class APIController extends OCSController {
public function __construct(
Expand Down Expand Up @@ -80,8 +81,8 @@ public function generateNotification(string $userId, string $shortMessage, strin
* @param string $userId ID of the user
* @param string $subject Subject of the notification
* @param string $message Message of the notification
* @param array<string, NotificationsRichObjectParameter> $subjectParameters Rich objects to fill the subject placeholders, {@see \OCP\RichObjectStrings\Definitions}
* @param array<string, NotificationsRichObjectParameter> $messageParameters Rich objects to fill the message placeholders, {@see \OCP\RichObjectStrings\Definitions}
* @param NotificationsRichObjectParameters $subjectParameters Rich objects to fill the subject placeholders, {@see \OCP\RichObjectStrings\Definitions}
* @param NotificationsRichObjectParameters $messageParameters Rich objects to fill the message placeholders, {@see \OCP\RichObjectStrings\Definitions}
* @return DataResponse<Http::STATUS_OK, array{id: int}, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: string}, array{}>
*
* 200: Notification generated successfully, returned id is the notification ID for future delete requests
Expand Down Expand Up @@ -114,11 +115,9 @@ public function generateNotificationV3(

try {
if (!empty($subjectParameters)) {
/** @psalm-var array<non-empty-string, array<non-empty-string, string>> $subjectParameters */
$this->richValidator->validate($subject, $subjectParameters);
}
if ($message !== '' && !empty($messageParameters)) {
/** @psalm-var array<non-empty-string, array<non-empty-string, string>> $messageParameters */
$this->richValidator->validate($message, $messageParameters);
}
$notification->setApp('admin_notifications')
Expand Down
6 changes: 4 additions & 2 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* height?: string,
* }
*
* @psalm-type NotificationsRichObjectParameters = array<non-empty-string, NotificationsRichObjectParameter>
*
* @psalm-type NotificationsNotificationAction = array{
* label: string,
* link: string,
Expand All @@ -59,9 +61,9 @@
* link: string,
* actions: list<NotificationsNotificationAction>,
* subjectRich?: string,
* subjectRichParameters?: array<string, NotificationsRichObjectParameter>,
* subjectRichParameters?: NotificationsRichObjectParameters,
* messageRich?: string,
* messageRichParameters?: array<string, NotificationsRichObjectParameter>,
* messageRichParameters?: NotificationsRichObjectParameters,
* icon?: string,
* shouldNotify?: bool,
* }
Expand Down
24 changes: 12 additions & 12 deletions openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@
"type": "string"
}
}
},
"RichObjectParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
}
}
},
Expand Down Expand Up @@ -422,20 +428,14 @@
"description": "Message of the notification"
},
"subjectParameters": {
"type": "object",
"default": {},
"description": "Rich objects to fill the subject placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters",
"default": [],
"description": "Rich objects to fill the subject placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}"
},
"messageParameters": {
"type": "object",
"default": {},
"description": "Rich objects to fill the message placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters",
"default": [],
"description": "Rich objects to fill the message placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}"
}
}
}
Expand Down
34 changes: 14 additions & 20 deletions openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,13 @@
"type": "string"
},
"subjectRichParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters"
},
"messageRich": {
"type": "string"
},
"messageRichParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters"
},
"icon": {
"type": "string"
Expand Down Expand Up @@ -304,6 +298,12 @@
"type": "string"
}
}
},
"RichObjectParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
}
}
},
Expand Down Expand Up @@ -1226,20 +1226,14 @@
"description": "Message of the notification"
},
"subjectParameters": {
"type": "object",
"default": {},
"description": "Rich objects to fill the subject placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters",
"default": [],
"description": "Rich objects to fill the subject placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}"
},
"messageParameters": {
"type": "object",
"default": {},
"description": "Rich objects to fill the message placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters",
"default": [],
"description": "Rich objects to fill the message placeholders, {@see \\OCP\\RichObjectStrings\\Definitions}"
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,13 @@
"type": "string"
},
"subjectRichParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters"
},
"messageRich": {
"type": "string"
},
"messageRichParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
"$ref": "#/components/schemas/RichObjectParameters"
},
"icon": {
"type": "string"
Expand Down Expand Up @@ -285,6 +279,12 @@
"type": "string"
}
}
},
"RichObjectParameters": {
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/RichObjectParameter"
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/openapi-extractor/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"sort-packages": true
},
"require-dev": {
"nextcloud/openapi-extractor": "^1.0"
"nextcloud/openapi-extractor": "^1.2.1"
}
}
20 changes: 10 additions & 10 deletions vendor-bin/openapi-extractor/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading