mirror of https://github.com/matrix-org/gomatrix
Added SendFile function, and FileMessage and FileInfo data structs
This commit is contained in:
parent
372e8fa06f
commit
d0c8c3e5b0
15
client.go
15
client.go
|
@ -450,6 +450,21 @@ func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {
|
||||||
TextMessage{"m.text", text})
|
TextMessage{"m.text", text})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendFile sends an m.room.message event into the given room with a msgtype of m.file
|
||||||
|
// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-file
|
||||||
|
// FIXME add thumbnail support
|
||||||
|
func (cli *Client) SendFile(roomID, body, url, filename string, info FileInfo, thumb_info, thumb_url interface{}) (*RespSendEvent, error) {
|
||||||
|
return cli.SendMessageEvent(roomID, "m.room.message",
|
||||||
|
FileMessage{
|
||||||
|
MsgType: "m.file",
|
||||||
|
Body: body,
|
||||||
|
URL: url,
|
||||||
|
FileName: filename,
|
||||||
|
Info: info,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SendImage sends an m.room.message event into the given room with a msgtype of m.image
|
// SendImage sends an m.room.message event into the given room with a msgtype of m.image
|
||||||
// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
|
// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
|
||||||
func (cli *Client) SendImage(roomID, body, url string) (*RespSendEvent, error) {
|
func (cli *Client) SendImage(roomID, body, url string) (*RespSendEvent, error) {
|
||||||
|
|
16
events.go
16
events.go
|
@ -44,6 +44,12 @@ type TextMessage struct {
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileInfo contains info about an image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-file
|
||||||
|
type FileInfo struct {
|
||||||
|
MimeType string `json:"mimetype,omitempty"`
|
||||||
|
Size uint `json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ImageInfo contains info about an image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
|
// ImageInfo contains info about an image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
|
||||||
type ImageInfo struct {
|
type ImageInfo struct {
|
||||||
Height uint `json:"h,omitempty"`
|
Height uint `json:"h,omitempty"`
|
||||||
|
@ -71,6 +77,16 @@ type VideoMessage struct {
|
||||||
Info VideoInfo `json:"info"`
|
Info VideoInfo `json:"info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileMessage is an m.file event
|
||||||
|
type FileMessage struct {
|
||||||
|
MsgType string `json:"msgtype"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
FileName string `json:"filename"`
|
||||||
|
Info FileInfo `json:"info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ImageMessage is an m.image event
|
// ImageMessage is an m.image event
|
||||||
type ImageMessage struct {
|
type ImageMessage struct {
|
||||||
MsgType string `json:"msgtype"`
|
MsgType string `json:"msgtype"`
|
||||||
|
|
Loading…
Reference in New Issue