From ace302431c41d5bdd6ad502532a6b4784d294560 Mon Sep 17 00:00:00 2001 From: Andreas Peters Date: Wed, 6 Sep 2017 15:06:53 +0200 Subject: [PATCH 1/3] add msgtype m.file --- client.go | 11 +++++++++++ events.go | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/client.go b/client.go index 90a07c6..59fda86 100644 --- a/client.go +++ b/client.go @@ -486,6 +486,17 @@ func (cli *Client) SendVideo(roomID, body, url string) (*RespSendEvent, error) { }) } +// SendImage send an m.room.message event intor the given room with a msgtyope of m.file +// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-file +func (cli *Client) SendFile(roomID, body, url string) (*RespSendEvent, error) { + return cli.SendMessageEvent(roomID, "m.room.message", + FileMessage{ + MsgType: "m.file", + Body: body, + URL: url, + }) +} + // SendNotice sends an m.room.message event into the given room with a msgtype of m.notice // See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-notice func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error) { diff --git a/events.go b/events.go index 7427740..2e92db3 100644 --- a/events.go +++ b/events.go @@ -86,6 +86,18 @@ type HTMLMessage struct { Format string `json:"format"` FormattedBody string `json:"formatted_body"` } +// An FileMessage is the contents of a MATRIX File upload +type FileMessage struct { + Body string `json:"body"` + MsgType string `json:"msgtype"` + URL string `json:"url"` + Info FileInfo `json:"info"` +} + +type FileInfo struct { + MimeType string `json:"mimetype"` + Size int64 `json:size"` +} var htmlRegex = regexp.MustCompile("<[^<]+?>") From 759911797e945614d4907e0cc555013e165c33af Mon Sep 17 00:00:00 2001 From: Andreas Peters Date: Wed, 6 Sep 2017 15:45:25 +0200 Subject: [PATCH 2/3] add comments --- events.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/events.go b/events.go index 2e92db3..d8fb375 100644 --- a/events.go +++ b/events.go @@ -86,17 +86,19 @@ type HTMLMessage struct { Format string `json:"format"` FormattedBody string `json:"formatted_body"` } + // An FileMessage is the contents of a MATRIX File upload type FileMessage struct { - Body string `json:"body"` - MsgType string `json:"msgtype"` - URL string `json:"url"` + Body string `json:"body"` + MsgType string `json:"msgtype"` + URL string `json:"url"` Info FileInfo `json:"info"` } +// FileInfo contains information about a file type FileInfo struct { MimeType string `json:"mimetype"` - Size int64 `json:size"` + Size int64 `json:size"` } var htmlRegex = regexp.MustCompile("<[^<]+?>") From 7fd6c722de5d7f1423a7109889e1c7d1651bfd2f Mon Sep 17 00:00:00 2001 From: Andreas Peters Date: Wed, 6 Sep 2017 15:48:47 +0200 Subject: [PATCH 3/3] add some missing comments --- client.go | 2 +- events.go | 2 +- responses.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 59fda86..562b2c4 100644 --- a/client.go +++ b/client.go @@ -486,7 +486,7 @@ func (cli *Client) SendVideo(roomID, body, url string) (*RespSendEvent, error) { }) } -// SendImage send an m.room.message event intor the given room with a msgtyope of m.file +// SendFile send an m.room.message event intor the given room with a msgtyope of m.file // See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-file func (cli *Client) SendFile(roomID, body, url string) (*RespSendEvent, error) { return cli.SendMessageEvent(roomID, "m.room.message", diff --git a/events.go b/events.go index d8fb375..deed4ad 100644 --- a/events.go +++ b/events.go @@ -98,7 +98,7 @@ type FileMessage struct { // FileInfo contains information about a file type FileInfo struct { MimeType string `json:"mimetype"` - Size int64 `json:size"` + Size int64 `json:"size"` } var htmlRegex = regexp.MustCompile("<[^<]+?>") diff --git a/responses.go b/responses.go index fe0eeb3..a4ba38e 100644 --- a/responses.go +++ b/responses.go @@ -168,6 +168,7 @@ type RespSync struct { } `json:"rooms"` } +// RespTurnServer have information about the Rurtn Server Authentication type RespTurnServer struct { Username string `json:"username"` Password string `json:"password"`