Send file names as captions when sending files and images.
This commit is contained in:
parent
28c829c2c8
commit
1703c091a7
|
@ -110,7 +110,7 @@ updateMarkdown m { roomId, text, markdown } =
|
||||||
in
|
in
|
||||||
({ m | transactionId = m.transactionId + 1 }, Cmd.batch [ storeValueCmd, sendMessageCmd ])
|
({ m | transactionId = m.transactionId + 1 }, Cmd.batch [ storeValueCmd, sendMessageCmd ])
|
||||||
|
|
||||||
updateFileUploadComplete : Model -> RoomId -> String -> (Result Http.Error String) -> (Model, Cmd Msg)
|
updateFileUploadComplete : Model -> RoomId -> File -> (Result Http.Error String) -> (Model, Cmd Msg)
|
||||||
updateFileUploadComplete m rid mime ur =
|
updateFileUploadComplete m rid mime ur =
|
||||||
let
|
let
|
||||||
command = case ur of
|
command = case ur of
|
||||||
|
@ -122,7 +122,7 @@ updateFileUploadComplete m rid mime ur =
|
||||||
in
|
in
|
||||||
({ m | errors = newErrors ++ m.errors, transactionId = m.transactionId + 1}, command)
|
({ m | errors = newErrors ++ m.errors, transactionId = m.transactionId + 1}, command)
|
||||||
|
|
||||||
updateImageUploadComplete : Model -> RoomId -> String -> (Result Http.Error String) -> (Model, Cmd Msg)
|
updateImageUploadComplete : Model -> RoomId -> File -> (Result Http.Error String) -> (Model, Cmd Msg)
|
||||||
updateImageUploadComplete m rid mime ur =
|
updateImageUploadComplete m rid mime ur =
|
||||||
let
|
let
|
||||||
command = case ur of
|
command = case ur of
|
||||||
|
@ -134,7 +134,7 @@ updateImageUploadComplete m rid mime ur =
|
||||||
in
|
in
|
||||||
({ m | transactionId = m.transactionId + 1}, command)
|
({ m | transactionId = m.transactionId + 1}, command)
|
||||||
|
|
||||||
updateUploadSelected : Model -> RoomId -> File -> List File -> (String -> Result Http.Error String -> Msg) -> (Model, Cmd Msg)
|
updateUploadSelected : Model -> RoomId -> File -> List File -> (File -> Result Http.Error String -> Msg) -> (Model, Cmd Msg)
|
||||||
updateUploadSelected m rid f fs msg =
|
updateUploadSelected m rid f fs msg =
|
||||||
let
|
let
|
||||||
uploadCmds = List.map (uploadMediaFile m.apiUrl (Maybe.withDefault "" m.token) msg) (f::fs)
|
uploadCmds = List.map (uploadMediaFile m.apiUrl (Maybe.withDefault "" m.token) msg) (f::fs)
|
||||||
|
|
|
@ -53,13 +53,13 @@ sync apiUrl token nextBatch = request
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadMediaFile : ApiUrl -> ApiToken -> (String -> Result Http.Error String -> Msg) -> File -> Cmd Msg
|
uploadMediaFile : ApiUrl -> ApiToken -> (File -> Result Http.Error String -> Msg) -> File -> Cmd Msg
|
||||||
uploadMediaFile apiUrl token msg file = request
|
uploadMediaFile apiUrl token msg file = request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = authenticatedHeaders token
|
, headers = authenticatedHeaders token
|
||||||
, url = Builder.crossOrigin (fullMediaUrl apiUrl) [ "upload" ] [ Builder.string "filename" (name file) ]
|
, url = Builder.crossOrigin (fullMediaUrl apiUrl) [ "upload" ] [ Builder.string "filename" (name file) ]
|
||||||
, body = fileBody file
|
, body = fileBody file
|
||||||
, expect = expectJson (msg <| mime file) <| Json.Decode.field "content_uri" Json.Decode.string
|
, expect = expectJson (msg file) <| Json.Decode.field "content_uri" Json.Decode.string
|
||||||
, timeout = Nothing
|
, timeout = Nothing
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
}
|
}
|
||||||
|
@ -103,20 +103,20 @@ sendTextMessage apiUrl token transactionId room message = sendMessage apiUrl tok
|
||||||
, ("body", string message)
|
, ("body", string message)
|
||||||
]
|
]
|
||||||
|
|
||||||
sendImageMessage : ApiUrl -> ApiToken -> Int -> RoomId -> String -> String -> Cmd Msg
|
sendImageMessage : ApiUrl -> ApiToken -> Int -> RoomId -> File -> String -> Cmd Msg
|
||||||
sendImageMessage apiUrl token transactionId room mime message = sendMessage apiUrl token transactionId room SendImageResponse
|
sendImageMessage apiUrl token transactionId room file message = sendMessage apiUrl token transactionId room SendImageResponse
|
||||||
[ ("msgtype", string "m.image")
|
[ ("msgtype", string "m.image")
|
||||||
, ("body", string "Image")
|
, ("body", string <| name file)
|
||||||
, ("url", string message)
|
, ("url", string message)
|
||||||
, ("info", object [ ("mimetype", string mime) ])
|
, ("info", object [ ("mimetype", string <| mime file) ])
|
||||||
]
|
]
|
||||||
|
|
||||||
sendFileMessage : ApiUrl -> ApiToken -> Int -> RoomId -> String -> String -> Cmd Msg
|
sendFileMessage : ApiUrl -> ApiToken -> Int -> RoomId -> File -> String -> Cmd Msg
|
||||||
sendFileMessage apiUrl token transactionId room mime message = sendMessage apiUrl token transactionId room SendFileResponse
|
sendFileMessage apiUrl token transactionId room file message = sendMessage apiUrl token transactionId room SendFileResponse
|
||||||
[ ("msgtype", string "m.file")
|
[ ("msgtype", string "m.file")
|
||||||
, ("body", string "File")
|
, ("body", string <| name file)
|
||||||
, ("url", string message)
|
, ("url", string message)
|
||||||
, ("info", object [ ("mimetype", string mime) ])
|
, ("info", object [ ("mimetype", string <| mime file) ])
|
||||||
]
|
]
|
||||||
|
|
||||||
login : ApiUrl -> Username -> Password -> Cmd Msg
|
login : ApiUrl -> Username -> Password -> Cmd Msg
|
||||||
|
|
|
@ -59,8 +59,8 @@ type Msg =
|
||||||
| SendFiles RoomId
|
| SendFiles RoomId
|
||||||
| ImagesSelected RoomId File (List File)
|
| ImagesSelected RoomId File (List File)
|
||||||
| FilesSelected RoomId File (List File)
|
| FilesSelected RoomId File (List File)
|
||||||
| ImageUploadComplete RoomId String (Result Http.Error String)
|
| ImageUploadComplete RoomId File (Result Http.Error String)
|
||||||
| FileUploadComplete RoomId String (Result Http.Error String)
|
| FileUploadComplete RoomId File (Result Http.Error String)
|
||||||
| SendImageResponse (Result Http.Error ())
|
| SendImageResponse (Result Http.Error ())
|
||||||
| SendFileResponse (Result Http.Error ())
|
| SendFileResponse (Result Http.Error ())
|
||||||
| ReceiveMarkdown MarkdownResponse
|
| ReceiveMarkdown MarkdownResponse
|
||||||
|
|
Loading…
Reference in New Issue
Block a user