Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OriginalContentURL & PreviewImageURL is Empty when receiving Image Message #237

Closed
hualoqueros opened this issue Oct 20, 2020 · 2 comments
Closed
Assignees
Labels

Comments

@hualoqueros
Copy link

System Informations

  • Go version: 1.13
  • OS: Linux

Expected Behavior

OriginalContentURL and PreviewImageURL is not Empty

Current Behavior

Base on Image Message documentation : https://developers.line.biz/en/reference/messaging-api/#wh-image
the payload is :

{
  "destination": "xxxxxxxxxx",
  "events": [
    {
      "replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
      "type": "message",
      "mode": "active",
      "timestamp": 1462629479859,
      "source": {
        "type": "user",
        "userId": "U4af4980629..."
      },
      "message": {
        "id": "325708",
        "type": "image",
        "contentProvider": {
          "type": "line"
        }
      }
    }
  ]
}

But i thing on this line code below in message.go file is not updated (hope i was wrong) for the image message payload (notice on contentProvider on payload example above)

...
// ImageMessage type
type ImageMessage struct {
	ID                 string
	OriginalContentURL string
	PreviewImageURL    string

	quickReplyitems *QuickReplyItems
	sender          *Sender
}

// MarshalJSON method of ImageMessage
func (m *ImageMessage) MarshalJSON() ([]byte, error) {
	return json.Marshal(&struct {
		Type               MessageType      `json:"type"`
		OriginalContentURL string           `json:"originalContentUrl"`
		PreviewImageURL    string           `json:"previewImageUrl"`
		QuickReply         *QuickReplyItems `json:"quickReply,omitempty"`
		Sender             *Sender          `json:"sender,omitempty"`
	}{
		Type:               MessageTypeImage,
		OriginalContentURL: m.OriginalContentURL,
		PreviewImageURL:    m.PreviewImageURL,
		QuickReply:         m.quickReplyitems,
		Sender:             m.sender,
	})
}
...

Steps to Reproduce

Logs

this is the log of *linebot.ImageMessage

&{ID:12888876884078 OriginalContentURL: PreviewImageURL: quickReplyitems:<nil> sender:<nil>}
@clsung
Copy link
Contributor

clsung commented Dec 8, 2020

contentProvider.originalContentUrl and contentProvider.previewImageUrl are only included when contentProvider.type is external.

@tokuhirom
Copy link
Member

I'll close this issue because @clsung already answered this question.

Note: https://developers.line.biz/en/reference/messaging-api/#wh-image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants