Skip to content

Commit 78ea408

Browse files
janepiejulien-nc
andcommitted
Apply suggestions from code review
Co-authored-by: Julien Veyssier <[email protected]> Signed-off-by: janepie <[email protected]>
1 parent 0ee19fc commit 78ea408

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ protected function run($argument): void {
9797
}
9898

9999
private function getTokens($webhookListener, $triggerUserId): array {
100-
$tokens = [];
100+
$tokens = [
101+
'users' => [],
102+
'functions' => [],
103+
];
101104
$tokenNeeded = $webhookListener->getTokenNeeded();
102105
if (isset($tokenNeeded['users'])) {
103106
foreach ($tokenNeeded['users'] as $userId) {

apps/webhook_listeners/lib/Controller/WebhooksController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function show(int $id): DataResponse {
113113
* @param "none"|"header"|null $authMethod Authentication method to use
114114
* @param ?array<string,mixed> $authData Array of data for authentication
115115
* @param ?array<string,mixed> $tokenNeeded List of user ids for which to include auth tokens in the event.
116-
* Has to fields: "users" lists uids of users for which tokens are needed, "functions" lists functions for which tokens can be included.
116+
* Has two fields: "users" list of user uids for which tokens are needed, "functions" list of functions for which tokens can be included.
117117
* Possible functions: "owner" for the user creating the webhook, "trigger" for the user triggering the webhook call
118118
*
119119
* @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo, array{}>
@@ -186,7 +186,7 @@ public function create(
186186
* @param "none"|"header"|null $authMethod Authentication method to use
187187
* @param ?array<string,mixed> $authData Array of data for authentication
188188
* @param ?array<string,mixed> $tokenNeeded List of user ids for which to include auth tokens in the event.
189-
* Has to fields: "users" lists uids of users for which tokens are needed, "functions" lists functions for which tokens can be included.
189+
* Has two fields: "users" list of user uids for which tokens are needed, "functions" list of functions for which tokens can be included.
190190
* Possible functions: "owner" for the user creating the webhook, "trigger" for the user triggering the webhook call
191191
*
192192
* @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo, array{}>

apps/webhook_listeners/lib/Db/WebhookListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ public function getAppId(): ?string {
169169
}
170170

171171

172-
public function createTemporaryToken($userId) {
172+
public function createTemporaryToken(string $userId): IToken {
173173
$token = $this->generateRandomDeviceToken();
174-
$name = 'Authentication for Webhook';
174+
$name = 'Ephemeral webhook authentication';
175175
$password = null;
176176
$deviceToken = $this->tokenProvider->generateToken($token, $userId, $userId, $password, $name, IToken::PERMANENT_TOKEN);
177177
return $token;
178178
}
179179

180-
private function generateRandomDeviceToken() {
180+
private function generateRandomDeviceToken(): string {
181181
$groups = [];
182182
for ($i = 0; $i < 5; $i++) {
183183
$groups[] = $this->random->generate(5, ISecureRandom::CHAR_HUMAN_READABLE);

0 commit comments

Comments
 (0)