2016-04-13 09:14:23 +03:00
|
|
|
package messenger
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
2016-04-14 02:53:55 +03:00
|
|
|
// Message represents a Facebook messenge message.
|
2016-04-13 09:14:23 +03:00
|
|
|
type Message struct {
|
2016-04-14 02:53:55 +03:00
|
|
|
// Sender is who the message was sent from.
|
|
|
|
Sender Sender `json:"-"`
|
|
|
|
// Recipient is who the message was sent to.
|
|
|
|
Recipient Recipient `json:"-"`
|
|
|
|
// Time is when the message was sent.
|
|
|
|
Time time.Time `json:"-"`
|
|
|
|
// Mid is the ID of the message.
|
|
|
|
Mid string `json:"mid"`
|
|
|
|
// Seq is order the message was sent in relation to other messages.
|
|
|
|
Seq int `json:"seq"`
|
|
|
|
// Text is the textual contents of the message.
|
|
|
|
Text string `json:"text"`
|
|
|
|
// Attachments is the information about the attachments which were sent
|
|
|
|
// with the message.
|
2016-04-13 12:46:52 +03:00
|
|
|
Attachments []Attachment `json:"attachments"`
|
2016-04-13 12:12:23 +03:00
|
|
|
}
|
|
|
|
|
2016-08-18 02:41:25 +03:00
|
|
|
// Delivery represents a the event fired when Facebook delivers a message to the
|
|
|
|
// recipient.
|
2016-04-13 12:12:23 +03:00
|
|
|
type Delivery struct {
|
2016-04-14 02:53:55 +03:00
|
|
|
// Mids are the IDs of the messages which were read.
|
|
|
|
Mids []string `json:"mids"`
|
2016-08-18 02:41:25 +03:00
|
|
|
// RawWatermark is the timestamp of when the delivery was.
|
|
|
|
RawWatermark int64 `json:"watermark"`
|
|
|
|
// Seq is the sequence the message was sent in.
|
|
|
|
Seq int `json:"seq"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delivery represents a the event fired when a message is read by the
|
|
|
|
// recipient.
|
|
|
|
type Read struct {
|
|
|
|
// RawWatermark is the timestamp before which all messages have been read
|
|
|
|
// by the user
|
2016-04-14 02:53:55 +03:00
|
|
|
RawWatermark int64 `json:"watermark"`
|
|
|
|
// Seq is the sequence the message was sent in.
|
|
|
|
Seq int `json:"seq"`
|
2016-04-13 12:36:38 +03:00
|
|
|
}
|
|
|
|
|
2016-05-03 16:42:25 +03:00
|
|
|
// PostBack represents postback callback
|
|
|
|
type PostBack struct {
|
2016-05-04 11:09:34 +03:00
|
|
|
// Sender is who the message was sent from.
|
2016-05-03 16:42:25 +03:00
|
|
|
Sender Sender `json:"-"`
|
|
|
|
// Recipient is who the message was sent to.
|
|
|
|
Recipient Recipient `json:"-"`
|
|
|
|
// Time is when the message was sent.
|
|
|
|
Time time.Time `json:"-"`
|
2016-05-04 11:09:34 +03:00
|
|
|
// PostBack ID
|
2016-05-03 16:42:25 +03:00
|
|
|
Payload string `json:"payload"`
|
|
|
|
}
|
|
|
|
|
2016-04-14 02:53:55 +03:00
|
|
|
// Watermark is the RawWatermark timestamp rendered as a time.Time.
|
2016-04-13 12:36:38 +03:00
|
|
|
func (d Delivery) Watermark() time.Time {
|
|
|
|
return time.Unix(d.RawWatermark, 0)
|
2016-04-13 09:14:23 +03:00
|
|
|
}
|
2016-08-18 02:41:25 +03:00
|
|
|
|
|
|
|
// Watermark is the RawWatermark timestamp rendered as a time.Time.
|
|
|
|
func (r Read) Watermark() time.Time {
|
|
|
|
return time.Unix(r.RawWatermark, 0)
|
|
|
|
}
|