Finish basic file upload support. Fixes #62

This commit is contained in:
Tulir Asokan
2020-09-02 02:12:09 +03:00
parent 1abf902392
commit 0aeedd2c43
8 changed files with 292 additions and 100 deletions

View File

@ -32,6 +32,14 @@ type Relation struct {
Event *muksevt.Event
}
type UploadedMediaInfo struct {
*mautrix.RespMediaUpload
EncryptionInfo *attachment.EncryptedFile
MsgType event.MessageType
Name string
Info *event.FileInfo
}
type MatrixContainer interface {
Client() *mautrix.Client
Preferences() *config.UserPreferences
@ -46,6 +54,7 @@ type MatrixContainer interface {
SendPreferencesToMatrix()
PrepareMarkdownMessage(roomID id.RoomID, msgtype event.MessageType, text, html string, relation *Relation) *muksevt.Event
PrepareMediaMessage(room *rooms.Room, path string, relation *Relation) (*muksevt.Event, error)
SendEvent(evt *muksevt.Event) (id.EventID, error)
Redact(roomID id.RoomID, eventID id.EventID, reason string) error
SendTyping(roomID id.RoomID, typing bool)
@ -60,8 +69,7 @@ type MatrixContainer interface {
GetRoom(roomID id.RoomID) *rooms.Room
GetOrCreateRoom(roomID id.RoomID) *rooms.Room
SendImage(roomID id.RoomID, body string, url id.ContentURI)
UploadMedia(data mautrix.ReqUploadMedia) (*id.ContentURI, error)
UploadMedia(path string, encrypt bool) (*UploadedMediaInfo, error)
Download(uri id.ContentURI, file *attachment.EncryptedFile) ([]byte, error)
DownloadToDisk(uri id.ContentURI, file *attachment.EncryptedFile, target string) (string, error)
GetDownloadURL(uri id.ContentURI) string