Showing
4 changed files
with
38 additions
and
5 deletions
| ... | @@ -126,6 +126,7 @@ This creates `config/daito-google-chat.php`. | ... | @@ -126,6 +126,7 @@ This creates `config/daito-google-chat.php`. |
| 126 | ```dotenv | 126 | ```dotenv |
| 127 | DAITO_GOOGLE_CHAT_ENABLED=true | 127 | DAITO_GOOGLE_CHAT_ENABLED=true |
| 128 | DAITO_GOOGLE_CHAT_WEBHOOK_URL=https://chat.googleapis.com/v1/spaces/.../messages?key=...&token=... | 128 | DAITO_GOOGLE_CHAT_WEBHOOK_URL=https://chat.googleapis.com/v1/spaces/.../messages?key=...&token=... |
| 129 | +DAITO_GOOGLE_CHAT_VERIFY_SSL=true | ||
| 129 | DAITO_GOOGLE_CHAT_QUEUE_NAME=google-chat | 130 | DAITO_GOOGLE_CHAT_QUEUE_NAME=google-chat |
| 130 | DAITO_GOOGLE_CHAT_RATE_LIMIT_ENABLED=true | 131 | DAITO_GOOGLE_CHAT_RATE_LIMIT_ENABLED=true |
| 131 | DAITO_GOOGLE_CHAT_RATE_LIMIT_MAX_JOBS=20 | 132 | DAITO_GOOGLE_CHAT_RATE_LIMIT_MAX_JOBS=20 |
| ... | @@ -234,6 +235,28 @@ redirect_stderr=true | ... | @@ -234,6 +235,28 @@ redirect_stderr=true |
| 234 | stdout_logfile=/var/log/supervisor/laravel-google-chat-worker.log | 235 | stdout_logfile=/var/log/supervisor/laravel-google-chat-worker.log |
| 235 | ``` | 236 | ``` |
| 236 | 237 | ||
| 238 | +### 10) Local WAMP + self-signed SSL (for webhook calls) | ||
| 239 | + | ||
| 240 | +If your local machine uses a self-signed certificate, keep `DAITO_GOOGLE_CHAT_VERIFY_SSL=true` and trust your local CA/cert in Windows. | ||
| 241 | + | ||
| 242 | +1. Download https://curl.se/ca/cacert.pem | ||
| 243 | +2. Put cacert.pem into C:\wamp64\bin\php | ||
| 244 | +3. Open php.ini and Edit as: | ||
| 245 | +``` | ||
| 246 | +curl.cainfo = "C:\php\extras\ssl\cacert.pem" | ||
| 247 | +openssl.cafile = "C:\php\extras\ssl\cacert.pem" | ||
| 248 | +``` | ||
| 249 | + | ||
| 250 | +4. Restart apache | ||
| 251 | + | ||
| 252 | +Quick local-only fallback (not recommended long-term): | ||
| 253 | + | ||
| 254 | +```dotenv | ||
| 255 | +DAITO_GOOGLE_CHAT_VERIFY_SSL=false | ||
| 256 | +``` | ||
| 257 | + | ||
| 258 | +Use this only for temporary debugging on local environment. Never disable SSL verification on production. | ||
| 259 | + | ||
| 237 | ## QueryLog (Laravel shared package) | 260 | ## QueryLog (Laravel shared package) |
| 238 | 261 | ||
| 239 | > **Provider registration note** | 262 | > **Provider registration note** | ... | ... |
| ... | @@ -6,18 +6,18 @@ use Illuminate\Support\Facades\RateLimiter; | ... | @@ -6,18 +6,18 @@ use Illuminate\Support\Facades\RateLimiter; |
| 6 | 6 | ||
| 7 | class DaitoGoogleChatRateLimitMiddleware | 7 | class DaitoGoogleChatRateLimitMiddleware |
| 8 | { | 8 | { |
| 9 | - public function handle($job, $next): void | 9 | + public function handle($job, $next) |
| 10 | { | 10 | { |
| 11 | $rateLimitKey = (string) config('daito-google-chat.rate_limit_key', 'daito-google-chat:webhook'); | 11 | $rateLimitKey = (string) config('daito-google-chat.rate_limit_key', 'daito-google-chat:webhook'); |
| 12 | $maxJobs = max(1, (int) config('daito-google-chat.rate_limit_max_jobs', 20)); | 12 | $maxJobs = max(1, (int) config('daito-google-chat.rate_limit_max_jobs', 20)); |
| 13 | $decaySeconds = max(1, (int) config('daito-google-chat.rate_limit_decay_seconds', 60)); | 13 | $decaySeconds = max(1, (int) config('daito-google-chat.rate_limit_decay_seconds', 60)); |
| 14 | 14 | ||
| 15 | if (RateLimiter::tooManyAttempts($rateLimitKey, $maxJobs)) { | 15 | if (RateLimiter::tooManyAttempts($rateLimitKey, $maxJobs)) { |
| 16 | - $job->release(max(1, RateLimiter::availableIn($rateLimitKey))); | 16 | + $job->release($decaySeconds); |
| 17 | return; | 17 | return; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | RateLimiter::hit($rateLimitKey, $decaySeconds); | 20 | RateLimiter::hit($rateLimitKey, $decaySeconds); |
| 21 | - $next($job); | 21 | + return $next($job); |
| 22 | } | 22 | } |
| 23 | } | 23 | } | ... | ... |
| ... | @@ -21,10 +21,19 @@ class DaitoGoogleChatWebhookClient | ... | @@ -21,10 +21,19 @@ class DaitoGoogleChatWebhookClient |
| 21 | $resolvedWebhookUrl = $this->resolveWebhookUrl($webhookUrl); | 21 | $resolvedWebhookUrl = $this->resolveWebhookUrl($webhookUrl); |
| 22 | $this->assertWebhookUrlIsAllowed($resolvedWebhookUrl); | 22 | $this->assertWebhookUrlIsAllowed($resolvedWebhookUrl); |
| 23 | 23 | ||
| 24 | - $response = Http::acceptJson() | 24 | + $response = Http::withHeaders( |
| 25 | + array( | ||
| 26 | + 'Accept' => 'application/json', | ||
| 27 | + ) | ||
| 28 | + ) | ||
| 25 | ->asJson() | 29 | ->asJson() |
| 30 | + ->withOptions( | ||
| 31 | + array( | ||
| 32 | + 'connect_timeout' => (int) config('daito-google-chat.connect_timeout_seconds', 3), | ||
| 33 | + 'verify' => (bool) config('daito-google-chat.verify_ssl', true), | ||
| 34 | + ) | ||
| 35 | + ) | ||
| 26 | ->timeout((int) config('daito-google-chat.timeout_seconds', 5)) | 36 | ->timeout((int) config('daito-google-chat.timeout_seconds', 5)) |
| 27 | - ->connectTimeout((int) config('daito-google-chat.connect_timeout_seconds', 3)) | ||
| 28 | ->retry( | 37 | ->retry( |
| 29 | (int) config('daito-google-chat.retry_times', 1), | 38 | (int) config('daito-google-chat.retry_times', 1), |
| 30 | (int) config('daito-google-chat.retry_sleep_ms', 200) | 39 | (int) config('daito-google-chat.retry_sleep_ms', 200) | ... | ... |
| ... | @@ -9,6 +9,7 @@ return array( | ... | @@ -9,6 +9,7 @@ return array( |
| 9 | ), | 9 | ), |
| 10 | 'timeout_seconds' => env('DAITO_GOOGLE_CHAT_TIMEOUT', 5), | 10 | 'timeout_seconds' => env('DAITO_GOOGLE_CHAT_TIMEOUT', 5), |
| 11 | 'connect_timeout_seconds' => env('DAITO_GOOGLE_CHAT_CONNECT_TIMEOUT', 3), | 11 | 'connect_timeout_seconds' => env('DAITO_GOOGLE_CHAT_CONNECT_TIMEOUT', 3), |
| 12 | + 'verify_ssl' => env('DAITO_GOOGLE_CHAT_VERIFY_SSL', true), | ||
| 12 | 'retry_times' => env('DAITO_GOOGLE_CHAT_RETRY_TIMES', 1), | 13 | 'retry_times' => env('DAITO_GOOGLE_CHAT_RETRY_TIMES', 1), |
| 13 | 'retry_sleep_ms' => env('DAITO_GOOGLE_CHAT_RETRY_SLEEP_MS', 200), | 14 | 'retry_sleep_ms' => env('DAITO_GOOGLE_CHAT_RETRY_SLEEP_MS', 200), |
| 14 | 'queue_connection' => env('DAITO_GOOGLE_CHAT_QUEUE_CONNECTION', null), | 15 | 'queue_connection' => env('DAITO_GOOGLE_CHAT_QUEUE_CONNECTION', null), | ... | ... |
-
Please register or sign in to post a comment