File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 3
3
require 'line-bot-api'
4
4
5
5
set :environment , :production
6
- set :app_base_url , ENV [ 'APP_BASE_URL' ]
6
+ set :app_base_url , ENV . fetch ( 'APP_BASE_URL' , nil )
7
7
8
8
THUMBNAIL_URL = 'https://via.placeholder.com/1024x1024'
9
9
HORIZONTAL_THUMBNAIL_URL = 'https://via.placeholder.com/1024x768'
@@ -39,6 +39,23 @@ def parser
39
39
@parser ||= Line ::Bot ::V2 ::WebhookParser . new ( channel_secret : ENV . fetch ( "LINE_CHANNEL_SECRET" ) )
40
40
end
41
41
42
+ configure do
43
+ if settings . app_base_url
44
+ webhook_endpoint = "#{ settings . app_base_url } /callback"
45
+ body , code , _ = client . set_webhook_endpoint_with_http_info ( set_webhook_endpoint_request : Line ::Bot ::V2 ::MessagingApi ::SetWebhookEndpointRequest . new (
46
+ endpoint : webhook_endpoint
47
+ ) )
48
+
49
+ if code == 200
50
+ p "✅ LINE Webhook URL set to #{ webhook_endpoint } "
51
+ else
52
+ p "❌ Failed to set LINE Webhook. code=#{ code } , error body=#{ body } "
53
+ end
54
+ else
55
+ p "⚠️ APP_BASE_URL is not set; skipping LINE Webhook auto-configuration."
56
+ end
57
+ end
58
+
42
59
post '/callback' do
43
60
body = request . body . read
44
61
signature = request . env [ 'HTTP_X_LINE_SIGNATURE' ]
You can’t perform that action at this time.
0 commit comments