Skip to content

Commit ff00e8c

Browse files
nickvergessenbackportbot[bot]
authored andcommitted
fix(bots): Add a constant for the protocol
Signed-off-by: Joas Schilling <[email protected]>
1 parent 2463ce2 commit ff00e8c

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Diff for: lib/Command/Bot/Install.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8181

8282
if (!empty($input->getOption('feature'))) {
8383
$featureFlags = Bot::featureLabelsToFlags($input->getOption('feature'));
84-
if (str_starts_with($url, 'nextcloudapp://')) {
84+
if (str_starts_with($url, Bot::URL_APP_PREFIX)) {
8585
$featureFlags &= ~Bot::FEATURE_WEBHOOK;
8686
}
87-
} elseif (str_starts_with($url, 'nextcloudapp://')) {
87+
} elseif (str_starts_with($url, Bot::URL_APP_PREFIX)) {
8888
$featureFlags = Bot::FEATURE_EVENT;
8989
} else {
9090
$featureFlags = Bot::FEATURE_WEBHOOK + Bot::FEATURE_RESPONSE;

Diff for: lib/Model/Bot.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Bot {
2323
public const FEATURE_LABEL_WEBHOOK = 'webhook';
2424
public const FEATURE_LABEL_RESPONSE = 'response';
2525
public const FEATURE_LABEL_EVENT = 'event';
26+
public const URL_APP_PREFIX = 'nextcloudapp://';
2627

2728
public const FEATURE_MAP = [
2829
self::FEATURE_NONE => self::FEATURE_LABEL_NONE,

Diff for: lib/Service/BotService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public function validateBotParameters(string $name, string $secret, string $url,
406406
throw new \InvalidArgumentException('The provided secret is too short (min. 40 chars, max. 128 chars)');
407407
}
408408

409-
if (!$url || strlen($url) > 4000 || !(str_starts_with($url, 'http://') || str_starts_with($url, 'https://') || str_starts_with($url, 'nextcloudapp://'))) {
409+
if (!$url || strlen($url) > 4000 || !(str_starts_with($url, 'http://') || str_starts_with($url, 'https://') || str_starts_with($url, Bot::URL_APP_PREFIX))) {
410410
throw new \InvalidArgumentException('The provided URL is not a valid URL');
411411
}
412412

0 commit comments

Comments
 (0)