Skip to content

Commit 3ec8e8f

Browse files
authored
Merge pull request #36 from noplanman/fix_getupdates_secret
Secret should not be required for getUpdates when called via CLI.
2 parents f83dd12 + 403687a commit 3ec8e8f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
99
### Deprecated
1010
### Removed
1111
### Fixed
12+
- Secret should not be required when using CLI for getUpdates.
1213
### Security
1314

1415
## [1.2.0] - 2017-07-10

src/Params.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@ private function validateAndSetBotParamsVital(array $params)
152152
private function validateAndSetBotParamsSpecial(array $params)
153153
{
154154
// Special case, where secret MUST be defined if we have a webhook.
155-
if (($params['webhook'] ?? null) && !($params['secret'] ?? null)) {
156-
throw new InvalidParamsException('Some vital info is missing: secret');
155+
if (($params['webhook']['url'] ?? null) && !($params['secret'] ?? null)) {
156+
// This does not apply when using CLI, but make sure it gets tested for!
157+
if ('cli' !== PHP_SAPI || BotManager::inTest()) {
158+
throw new InvalidParamsException('Some vital info is missing: secret');
159+
}
157160
}
158161
}
159162

0 commit comments

Comments
 (0)