line-bot-sdk-ruby icon indicating copy to clipboard operation
line-bot-sdk-ruby copied to clipboard

DateTimePicker Action is not working properly

Open dnt294 opened this issue 4 years ago • 3 comments

System Informations

  • Ruby version: 2.5.3
  • Gem (line-bot-api) version: 1.23.0
  • OS: macOS Monterey 12.2.1

Expected Behavior

I create a DateTime Picker Action. This should return a DateTimePicker with initial/min/max values matched with JSON-request setup.

Current Behavior

  1. When I send JSON with content like this
"action": {
  "type": "datetimepicker",
  "label": "Select date",
  "data": "storeId=12345",
  "mode": "datetime",
  "initial": "2022-02-25t00:00",
  "max": "2023-01-24t00:00",
  "min": "2022-01-25t00:00"
}

What I got in Mobile app is the initial value is set to current datetime (of my phone) , (while max and min value are unknown) image

  1. If I change the JSON content like this (remove the t00:00 part - which is still valid due to API doc, the action never returned (so could it be invalid formatted ? 🤔 )
"action": {
  "type": "datetimepicker",
  "label": "Select date",
  "data": "storeId=12345",
  "mode": "datetime",
  "initial": "2022-02-25",
  "max": "2023-01-24",
  "min": "2022-01-25"
}

Steps to Reproduce

I'm setting up this in my source code

def client
  ::Line::Bot::Client.new do |config|
    config.channel_id = chat_service_manager.line_channel_id
    config.channel_secret = chat_service_manager.line_secret_token
    config.channel_token = chat_service_manager.line_access_token
  end
end

...

@messages = normalize_service.normalized_sequences
Rails.logger.info "MESSAGES SENT TO LINE API !"
Rails.logger.info @messages

...

response = client.reply_message(@options[:reply_token], @messages)

Logs

Then I got this from my logger (corresponding to case 1 and 2 above)

Case 1 image

Case 2 image

dnt294 avatar Feb 13 '22 11:02 dnt294

Raw HTTP response for Case 2

{
  "message": "A message (messages[0]) in the request body is invalid",
  "details": [
    {
      "message": "invalid datetime format for the specified mode",
      "property": "/footer/contents/1/action/initial"
    },
    {
      "message": "invalid datetime format for the specified mode",
      "property": "/footer/contents/1/action/max"
    },
    {
      "message": "invalid datetime format for the specified mode",
      "property": "/footer/contents/1/action/min"
    }
  ]
}

This seems reasonable: see https://developers.line.biz/en/reference/messaging-api/#date-and-time-format

For Case 1, changing t to T fixes the problem you described.

I think this is indeed a bug (in spec or in implementation), but still do not know this repo is appropriate place to report it.

yskkin avatar Feb 15 '22 06:02 yskkin

Thanks for explanation it. I will escalating to fix document for co-worker. (Case ~2~ 1)

kimoto avatar Feb 15 '22 07:02 kimoto

As yskkin-san says, please try using mode:date (Case ~1~ 2)

kimoto avatar Feb 15 '22 08:02 kimoto

@dnt294 san Thank you for reporting the issue. This issue has been fixed in the following versions of LINE app:

  • LINE for Android 12.18.0
  • LINE for iOS 12.15.0

Please report any further problems. Thanks!

zenizh avatar Nov 07 '22 10:11 zenizh