1
0
mirror of synced 2024-11-22 12:56:06 +03:00

Add documentation to Message and Delivery

This commit is contained in:
Harrison 2016-04-14 09:53:55 +10:00
parent f98f5920a3
commit c2ae2a3f30

View File

@ -2,22 +2,37 @@ package messenger
import "time" import "time"
// Message represents a Facebook messenge message.
type Message struct { type Message struct {
Sender Sender `json:"-"` // Sender is who the message was sent from.
Recipient Recipient `json:"-"` Sender Sender `json:"-"`
Time time.Time `json:"-"` // Recipient is who the message was sent to.
Mid string `json:"mid"` Recipient Recipient `json:"-"`
Text string `json:"text"` // Time is when the message was sent.
Seq int `json:"seq"` 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.
Attachments []Attachment `json:"attachments"` Attachments []Attachment `json:"attachments"`
} }
// Delivery represents a the event fired when a recipient reads one of Messengers sent
// messages.
type Delivery struct { type Delivery struct {
Mids []string `json:"mids"` // Mids are the IDs of the messages which were read.
RawWatermark int64 `json:"watermark"` Mids []string `json:"mids"`
Seq int `json:"seq"` // RawWatermark is the timestamp contained in the message of when the read was.
RawWatermark int64 `json:"watermark"`
// Seq is the sequence the message was sent in.
Seq int `json:"seq"`
} }
// Watermark is the RawWatermark timestamp rendered as a time.Time.
func (d Delivery) Watermark() time.Time { func (d Delivery) Watermark() time.Time {
return time.Unix(d.RawWatermark, 0) return time.Unix(d.RawWatermark, 0)
} }