Add markdown sending.
This commit is contained in:
@@ -76,6 +76,14 @@ sendMessage apiUrl token transactionId room msg contents = request
|
||||
, tracker = Nothing
|
||||
}
|
||||
|
||||
sendMarkdownMessage : ApiUrl -> ApiToken -> Int -> RoomId -> String -> String -> Cmd Msg
|
||||
sendMarkdownMessage apiUrl token transactionId room message md = sendMessage apiUrl token transactionId room SendRoomTextResponse
|
||||
[ ("msgtype", string "m.text")
|
||||
, ("body", string message)
|
||||
, ("formatted_body", string md)
|
||||
, ("format", string "org.matrix.custom.html")
|
||||
]
|
||||
|
||||
sendTextMessage : ApiUrl -> ApiToken -> Int -> RoomId -> String -> Cmd Msg
|
||||
sendTextMessage apiUrl token transactionId room message = sendMessage apiUrl token transactionId room SendRoomTextResponse
|
||||
[ ("msgtype", string "m.text")
|
||||
|
||||
15
src/Scylla/Markdown.elm
Normal file
15
src/Scylla/Markdown.elm
Normal file
@@ -0,0 +1,15 @@
|
||||
port module Scylla.Markdown exposing (..)
|
||||
|
||||
type alias MarkdownRequest =
|
||||
{ roomId : String
|
||||
, text : String
|
||||
}
|
||||
|
||||
type alias MarkdownResponse =
|
||||
{ roomId : String
|
||||
, text : String
|
||||
, markdown : String
|
||||
}
|
||||
|
||||
port requestMarkdownPort : MarkdownRequest -> Cmd msg
|
||||
port receiveMarkdownPort : (MarkdownResponse -> msg) -> Sub msg
|
||||
@@ -5,6 +5,7 @@ import Scylla.Login exposing (LoginResponse, Username, Password)
|
||||
import Scylla.UserData exposing (UserData)
|
||||
import Scylla.Route exposing (Route(..), RoomId)
|
||||
import Scylla.Storage exposing (..)
|
||||
import Scylla.Markdown exposing (..)
|
||||
import Browser.Navigation as Nav
|
||||
import Browser.Dom exposing (Viewport)
|
||||
import Url.Builder
|
||||
@@ -61,6 +62,7 @@ type Msg =
|
||||
| FileUploadComplete RoomId String (Result Http.Error String)
|
||||
| SendImageResponse (Result Http.Error ())
|
||||
| SendFileResponse (Result Http.Error ())
|
||||
| ReceiveMarkdown MarkdownResponse
|
||||
|
||||
displayName : Model -> Username -> String
|
||||
displayName m s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s m.userData
|
||||
|
||||
Reference in New Issue
Block a user