Merge pull request #28 from noordstar/patch-no-baseurl-found
Default to original server name if no well-known foundpull/29/head
commit
425d964af5
|
@ -35,9 +35,10 @@ import Internal.Api.Request as Request
|
||||||
import Internal.Api.SendMessageEvent.Api
|
import Internal.Api.SendMessageEvent.Api
|
||||||
import Internal.Api.Versions.Api
|
import Internal.Api.Versions.Api
|
||||||
import Internal.Config.Log exposing (Log, log)
|
import Internal.Config.Log exposing (Log, log)
|
||||||
|
import Internal.Config.Text as Text
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
import Internal.Values.Context as Context exposing (APIContext)
|
import Internal.Values.Context as Context exposing (APIContext)
|
||||||
import Internal.Values.Envelope exposing (EnvelopeUpdate(..))
|
import Internal.Values.Envelope as E exposing (EnvelopeUpdate(..))
|
||||||
import Internal.Values.Room exposing (RoomUpdate(..))
|
import Internal.Values.Room exposing (RoomUpdate(..))
|
||||||
import Internal.Values.Vault exposing (VaultUpdate(..))
|
import Internal.Values.Vault exposing (VaultUpdate(..))
|
||||||
import Task
|
import Task
|
||||||
|
@ -111,7 +112,20 @@ getBaseUrl c =
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Internal.Api.BaseUrl.Api.baseUrl
|
Internal.Api.BaseUrl.Api.baseUrl
|
||||||
{ url = Context.fromApiFormat c |> .serverName }
|
{ url = Context.fromApiFormat c |> .serverName }
|
||||||
c
|
|> C.catchWith
|
||||||
|
(\_ ->
|
||||||
|
let
|
||||||
|
url : String
|
||||||
|
url =
|
||||||
|
Context.fromApiFormat c
|
||||||
|
|> .serverName
|
||||||
|
in
|
||||||
|
{ contextChange = Context.setBaseUrl url
|
||||||
|
, logs = [ log.warn (Text.logs.baseUrlFailed url) ]
|
||||||
|
, messages = [ E.SetBaseUrl url ]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|> (|>) c
|
||||||
|
|
||||||
|
|
||||||
{-| Get the current timestamp
|
{-| Get the current timestamp
|
||||||
|
|
|
@ -609,7 +609,8 @@ happened. Most of these unexpected results, are taken account of by the Elm SDK,
|
||||||
but logged so that the programmer can do something about it.
|
but logged so that the programmer can do something about it.
|
||||||
-}
|
-}
|
||||||
logs :
|
logs :
|
||||||
{ baseUrlFound : String -> String -> String
|
{ baseUrlFailed : String -> String
|
||||||
|
, baseUrlFound : String -> String -> String
|
||||||
, getEventId : String -> String
|
, getEventId : String -> String
|
||||||
, getNow : Int -> String
|
, getNow : Int -> String
|
||||||
, httpRequest : String -> String -> String
|
, httpRequest : String -> String -> String
|
||||||
|
@ -621,7 +622,9 @@ logs :
|
||||||
, serverReturnedUnknownJSON : String -> String
|
, serverReturnedUnknownJSON : String -> String
|
||||||
}
|
}
|
||||||
logs =
|
logs =
|
||||||
{ baseUrlFound =
|
{ baseUrlFailed =
|
||||||
|
(++) "Failed to find .well-known, using default server address: "
|
||||||
|
, baseUrlFound =
|
||||||
\url baseUrl ->
|
\url baseUrl ->
|
||||||
String.concat [ "Found baseURL of ", url, " at address ", baseUrl ]
|
String.concat [ "Found baseURL of ", url, " at address ", baseUrl ]
|
||||||
, getEventId = (++) "Received event with id = "
|
, getEventId = (++) "Received event with id = "
|
||||||
|
|
Loading…
Reference in New Issue