Compare commits
No commits in common. "b32e0ef123ea16330185279503fdc1aac8d506b7" and "4349a14a8702bc435bb2924da87a365bf9d11b5a" have entirely different histories.
b32e0ef123
...
4349a14a87
|
@ -1,4 +1,4 @@
|
||||||
module Internal.Api.BaseUrl.Api exposing (baseUrl)
|
module Internal.Api.BaseUrl.Api exposing (..)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ module Internal.Api.BaseUrl.Api exposing (baseUrl)
|
||||||
|
|
||||||
This module looks for the right homeserver address.
|
This module looks for the right homeserver address.
|
||||||
|
|
||||||
@docs baseUrl
|
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Internal.Api.Chain as C
|
import Internal.Api.Chain as C
|
||||||
|
@ -21,8 +19,6 @@ import Internal.Values.Envelope as E
|
||||||
import Internal.Values.Vault as V
|
import Internal.Values.Vault as V
|
||||||
|
|
||||||
|
|
||||||
{-| Get the homeserver base URL of a given server name.
|
|
||||||
-}
|
|
||||||
baseUrl : BaseUrlInput -> C.TaskChain R.Error (E.EnvelopeUpdate V.VaultUpdate) ph { ph | baseUrl : () }
|
baseUrl : BaseUrlInput -> C.TaskChain R.Error (E.EnvelopeUpdate V.VaultUpdate) ph { ph | baseUrl : () }
|
||||||
baseUrl data =
|
baseUrl data =
|
||||||
R.toChain
|
R.toChain
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Internal.Api.Chain exposing
|
module Internal.Api.Chain exposing
|
||||||
( TaskChain, CompleteChain
|
( TaskChain, CompleteChain
|
||||||
, IdemChain, toTask
|
, IdemChain, toTask
|
||||||
, fail, succeed, andThen, catchWith, maybe
|
, fail, succeed, andThen, catchWith
|
||||||
)
|
)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
|
@ -27,7 +27,7 @@ avoid leaking values passing through the API in unexpected ways.
|
||||||
|
|
||||||
## Operations
|
## Operations
|
||||||
|
|
||||||
@docs fail, succeed, andThen, catchWith, maybe
|
@docs fail, succeed, andThen, catchWith
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,6 @@ import Internal.Values.Vault as V
|
||||||
import Json.Encode as E
|
import Json.Encode as E
|
||||||
|
|
||||||
|
|
||||||
{-| Log in using a username and password.
|
|
||||||
-}
|
|
||||||
loginWithUsernameAndPassword : LoginWithUsernameAndPasswordInput -> A.TaskChain (Phantom a) (Phantom { a | accessToken : () })
|
loginWithUsernameAndPassword : LoginWithUsernameAndPasswordInput -> A.TaskChain (Phantom a) (Phantom { a | accessToken : () })
|
||||||
loginWithUsernameAndPassword =
|
loginWithUsernameAndPassword =
|
||||||
A.startWithVersion "r0.0.0" loginWithUsernameAndPasswordV1
|
A.startWithVersion "r0.0.0" loginWithUsernameAndPasswordV1
|
||||||
|
@ -48,10 +46,8 @@ loginWithUsernameAndPassword =
|
||||||
|> A.versionChain
|
|> A.versionChain
|
||||||
|
|
||||||
|
|
||||||
{-| Context needed for logging in with a username and password
|
|
||||||
-}
|
|
||||||
type alias Phantom a =
|
type alias Phantom a =
|
||||||
{ a | baseUrl : (), now : (), versions : () }
|
{ a | baseUrl : (), versions : () }
|
||||||
|
|
||||||
|
|
||||||
type alias LoginWithUsernameAndPasswordInput =
|
type alias LoginWithUsernameAndPasswordInput =
|
||||||
|
|
|
@ -28,8 +28,6 @@ import Internal.Values.Context as Context
|
||||||
import Internal.Values.Envelope as E
|
import Internal.Values.Envelope as E
|
||||||
|
|
||||||
|
|
||||||
{-| Update message type that is being returned.
|
|
||||||
-}
|
|
||||||
type alias Msg =
|
type alias Msg =
|
||||||
Backpack
|
Backpack
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,6 @@ import Task
|
||||||
import Time
|
import Time
|
||||||
|
|
||||||
|
|
||||||
{-| Get the current time and place it in the context.
|
|
||||||
-}
|
|
||||||
getNow : A.TaskChain a { a | now : () }
|
getNow : A.TaskChain a { a | now : () }
|
||||||
getNow =
|
getNow =
|
||||||
\_ ->
|
\_ ->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Internal.Api.SendMessageEvent.Api exposing (Phantom, sendMessageEvent)
|
module Internal.Api.SendMessageEvent.Api exposing (..)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ module Internal.Api.SendMessageEvent.Api exposing (Phantom, sendMessageEvent)
|
||||||
|
|
||||||
This module helps send message events to rooms on the Matrix API.
|
This module helps send message events to rooms on the Matrix API.
|
||||||
|
|
||||||
@docs Phantom, sendMessageEvent
|
@docs Phantom
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@ import Internal.Tools.Json as Json
|
||||||
import Internal.Values.Envelope as E
|
import Internal.Values.Envelope as E
|
||||||
|
|
||||||
|
|
||||||
{-| Send a message event to the Matrix room.
|
|
||||||
-}
|
|
||||||
sendMessageEvent : SendMessageEventInput -> A.TaskChain (Phantom a) (Phantom a)
|
sendMessageEvent : SendMessageEventInput -> A.TaskChain (Phantom a) (Phantom a)
|
||||||
sendMessageEvent =
|
sendMessageEvent =
|
||||||
A.startWithVersion "r0.0.0" sendMessageEventV1
|
A.startWithVersion "r0.0.0" sendMessageEventV1
|
||||||
|
@ -46,10 +44,8 @@ sendMessageEvent =
|
||||||
|> A.versionChain
|
|> A.versionChain
|
||||||
|
|
||||||
|
|
||||||
{-| Context needed for sending a message event
|
|
||||||
-}
|
|
||||||
type alias Phantom a =
|
type alias Phantom a =
|
||||||
{ a | accessToken : (), baseUrl : (), versions : () }
|
a
|
||||||
|
|
||||||
|
|
||||||
type alias PhantomV1 a =
|
type alias PhantomV1 a =
|
||||||
|
|
|
@ -65,7 +65,7 @@ type alias UFTask a b =
|
||||||
|
|
||||||
{-| Get an access token to talk to the Matrix API
|
{-| Get an access token to talk to the Matrix API
|
||||||
-}
|
-}
|
||||||
getAccessToken : UFTask { a | baseUrl : (), now : (), versions : () } { a | accessToken : (), baseUrl : (), now : (), versions : () }
|
getAccessToken : UFTask { a | now : () } { a | accessToken : (), now : () }
|
||||||
getAccessToken c =
|
getAccessToken c =
|
||||||
case Context.fromApiFormat c of
|
case Context.fromApiFormat c of
|
||||||
context ->
|
context ->
|
||||||
|
|
|
@ -50,6 +50,8 @@ for interacting with the Matrix API.
|
||||||
import Internal.Config.Text as Text
|
import Internal.Config.Text as Text
|
||||||
import Internal.Grammar.UserId as U
|
import Internal.Grammar.UserId as U
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
|
import Json.Decode as D
|
||||||
|
import Json.Encode as E
|
||||||
import Set exposing (Set)
|
import Set exposing (Set)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ import Internal.Tools.Json as Json
|
||||||
import Internal.Values.Event as Event exposing (Event)
|
import Internal.Values.Event as Event exposing (Event)
|
||||||
import Internal.Values.StateManager as StateManager exposing (StateManager)
|
import Internal.Values.StateManager as StateManager exposing (StateManager)
|
||||||
import Internal.Values.Timeline as Timeline exposing (Timeline)
|
import Internal.Values.Timeline as Timeline exposing (Timeline)
|
||||||
import Internal.Values.User exposing (User)
|
import Internal.Values.User as User exposing (User)
|
||||||
import Json.Encode as E
|
import Json.Encode as E
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ update ru room =
|
||||||
AddSync batch ->
|
AddSync batch ->
|
||||||
addSync batch room
|
addSync batch room
|
||||||
|
|
||||||
Invite _ ->
|
Invite user ->
|
||||||
-- TODO: Invite user
|
-- TODO: Invite user
|
||||||
room
|
room
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ Since the username is safely parsed, one can get these parts of the username.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Internal.Config.Log exposing (log)
|
import Internal.Config.Log as Log exposing (log)
|
||||||
import Internal.Grammar.ServerName as ServerName
|
import Internal.Grammar.ServerName as ServerName
|
||||||
import Internal.Grammar.UserId as UserId
|
import Internal.Grammar.UserId as UserId
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
|
|
|
@ -33,6 +33,8 @@ Rooms are environments where people can have a conversation with each other.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import FastDict as Dict exposing (Dict)
|
import FastDict as Dict exposing (Dict)
|
||||||
|
import Internal.Api.Request as Request
|
||||||
|
import Internal.Config.Log exposing (Log)
|
||||||
import Internal.Config.Text as Text
|
import Internal.Config.Text as Text
|
||||||
import Internal.Tools.Hashdict as Hashdict exposing (Hashdict)
|
import Internal.Tools.Hashdict as Hashdict exposing (Hashdict)
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
|
|
|
@ -56,6 +56,6 @@ sent a new message? Did someone send us an invite for a new room?
|
||||||
-}
|
-}
|
||||||
update : VaultUpdate -> Vault -> Vault
|
update : VaultUpdate -> Vault -> Vault
|
||||||
update (VaultUpdate vu) (Vault vault) =
|
update (VaultUpdate vu) (Vault vault) =
|
||||||
vu.messages
|
vault
|
||||||
|> List.foldl (Envelope.update Internal.update) vault
|
|> Envelope.update Internal.update vu
|
||||||
|> Vault
|
|> Vault
|
||||||
|
|
|
@ -3,13 +3,10 @@ module Test.Values.Context exposing (..)
|
||||||
import Expect
|
import Expect
|
||||||
import Fuzz exposing (Fuzzer)
|
import Fuzz exposing (Fuzzer)
|
||||||
import Internal.Config.Leaks as Leaks
|
import Internal.Config.Leaks as Leaks
|
||||||
import Internal.Tools.Hashdict as Hashdict
|
import Internal.Values.Context as Context exposing (Context)
|
||||||
import Internal.Values.Context as Context exposing (Context, Versions)
|
|
||||||
import Json.Decode as D
|
import Json.Decode as D
|
||||||
import Json.Encode as E
|
import Json.Encode as E
|
||||||
import Set
|
|
||||||
import Test exposing (..)
|
import Test exposing (..)
|
||||||
import Test.Tools.Timestamp as TestTimestamp
|
|
||||||
|
|
||||||
|
|
||||||
fuzzer : Fuzzer Context
|
fuzzer : Fuzzer Context
|
||||||
|
@ -19,28 +16,14 @@ fuzzer =
|
||||||
maybeString =
|
maybeString =
|
||||||
Fuzz.maybe Fuzz.string
|
Fuzz.maybe Fuzz.string
|
||||||
in
|
in
|
||||||
Fuzz.map8 (\a b c d e f ( g, h ) ( i, j ) -> Context a b c d e f g h i j)
|
Fuzz.map7 Context
|
||||||
(Fuzz.constant <| Hashdict.empty .value)
|
|
||||||
maybeString
|
maybeString
|
||||||
maybeString
|
maybeString
|
||||||
(Fuzz.maybe TestTimestamp.fuzzer)
|
|
||||||
maybeString
|
maybeString
|
||||||
maybeString
|
maybeString
|
||||||
(Fuzz.pair
|
|
||||||
Fuzz.string
|
|
||||||
maybeString
|
maybeString
|
||||||
)
|
|
||||||
(Fuzz.pair
|
|
||||||
maybeString
|
maybeString
|
||||||
(Fuzz.maybe <| versionsFuzzer)
|
(Fuzz.maybe <| Fuzz.list Fuzz.string)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
versionsFuzzer : Fuzzer Versions
|
|
||||||
versionsFuzzer =
|
|
||||||
Fuzz.map2 Versions
|
|
||||||
(Fuzz.list Fuzz.string)
|
|
||||||
(Fuzz.map Set.fromList <| Fuzz.list Fuzz.string)
|
|
||||||
|
|
||||||
|
|
||||||
{-| If a leak is spotted, make sure to change the leaking value and then test
|
{-| If a leak is spotted, make sure to change the leaking value and then test
|
||||||
|
@ -81,7 +64,7 @@ leaks =
|
||||||
|> Expect.notEqual Leaks.transaction
|
|> Expect.notEqual Leaks.transaction
|
||||||
)
|
)
|
||||||
, fuzz2 fuzzer
|
, fuzz2 fuzzer
|
||||||
versionsFuzzer
|
(Fuzz.list Fuzz.string)
|
||||||
"Versions"
|
"Versions"
|
||||||
(\context value ->
|
(\context value ->
|
||||||
context
|
context
|
||||||
|
@ -127,7 +110,7 @@ apiContext =
|
||||||
|> Expect.equal value
|
|> Expect.equal value
|
||||||
)
|
)
|
||||||
, fuzz2 fuzzer
|
, fuzz2 fuzzer
|
||||||
versionsFuzzer
|
(Fuzz.list Fuzz.string)
|
||||||
"Versions"
|
"Versions"
|
||||||
(\context value ->
|
(\context value ->
|
||||||
context
|
context
|
||||||
|
@ -143,7 +126,7 @@ json : Test
|
||||||
json =
|
json =
|
||||||
describe "JSON encode + JSON decode"
|
describe "JSON encode + JSON decode"
|
||||||
[ test "Empty is {}"
|
[ test "Empty is {}"
|
||||||
(Context.init ""
|
(Context.init
|
||||||
|> Context.encode
|
|> Context.encode
|
||||||
|> E.encode 0
|
|> E.encode 0
|
||||||
|> Expect.equal "{}"
|
|> Expect.equal "{}"
|
||||||
|
|
|
@ -28,7 +28,7 @@ suite =
|
||||||
[ fuzz Fuzz.string
|
[ fuzz Fuzz.string
|
||||||
"currentVersion"
|
"currentVersion"
|
||||||
(\s ->
|
(\s ->
|
||||||
{ content = s, serverName = "" }
|
s
|
||||||
|> Envelope.init
|
|> Envelope.init
|
||||||
|> Envelope.extractSettings .currentVersion
|
|> Envelope.extractSettings .currentVersion
|
||||||
|> Expect.equal Default.currentVersion
|
|> Expect.equal Default.currentVersion
|
||||||
|
@ -36,7 +36,7 @@ suite =
|
||||||
, fuzz Fuzz.string
|
, fuzz Fuzz.string
|
||||||
"deviceName"
|
"deviceName"
|
||||||
(\s ->
|
(\s ->
|
||||||
{ content = s, serverName = "" }
|
s
|
||||||
|> Envelope.init
|
|> Envelope.init
|
||||||
|> Envelope.extractSettings .deviceName
|
|> Envelope.extractSettings .deviceName
|
||||||
|> Expect.equal Default.deviceName
|
|> Expect.equal Default.deviceName
|
||||||
|
@ -44,7 +44,7 @@ suite =
|
||||||
, fuzz Fuzz.string
|
, fuzz Fuzz.string
|
||||||
"syncTime"
|
"syncTime"
|
||||||
(\s ->
|
(\s ->
|
||||||
{ content = s, serverName = "" }
|
s
|
||||||
|> Envelope.init
|
|> Envelope.init
|
||||||
|> Envelope.extractSettings .syncTime
|
|> Envelope.extractSettings .syncTime
|
||||||
|> Expect.equal Default.syncTime
|
|> Expect.equal Default.syncTime
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
module Test.Values.Room exposing (..)
|
module Test.Values.Room exposing (..)
|
||||||
|
|
||||||
|
import Expect
|
||||||
import Fuzz exposing (Fuzzer)
|
import Fuzz exposing (Fuzzer)
|
||||||
import Internal.Values.Room as Room exposing (Room)
|
import Internal.Values.Room as Room exposing (Room)
|
||||||
|
import Json.Decode as D
|
||||||
import Json.Encode as E
|
import Json.Encode as E
|
||||||
import Test exposing (..)
|
import Test exposing (..)
|
||||||
import Test.Filter.Timeline as TestFilter
|
import Test.Filter.Timeline as TestFilter
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Test.Values.Timeline exposing (..)
|
||||||
|
|
||||||
import Expect
|
import Expect
|
||||||
import Fuzz exposing (Fuzzer)
|
import Fuzz exposing (Fuzzer)
|
||||||
import Internal.Filter.Timeline as Filter
|
import Internal.Filter.Timeline as Filter exposing (Filter)
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
import Internal.Values.Timeline as Timeline exposing (Batch, Timeline)
|
import Internal.Values.Timeline as Timeline exposing (Batch, Timeline)
|
||||||
import Json.Decode as D
|
import Json.Decode as D
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
module Test.Values.User exposing (..)
|
|
||||||
|
|
||||||
import Fuzz exposing (Fuzzer)
|
|
||||||
import Internal.Grammar.ServerName as SN
|
|
||||||
import Internal.Values.User exposing (User)
|
|
||||||
|
|
||||||
|
|
||||||
fuzzer : Fuzzer User
|
|
||||||
fuzzer =
|
|
||||||
Fuzz.constant
|
|
||||||
{ localpart = "temporary"
|
|
||||||
, domain = { host = SN.DNS "matrix.org", port_ = Nothing }
|
|
||||||
}
|
|
|
@ -1,22 +1,20 @@
|
||||||
module Test.Values.Vault exposing (..)
|
module Test.Values.Vault exposing (..)
|
||||||
|
|
||||||
import FastDict as Dict
|
import FastDict as Dict exposing (Dict)
|
||||||
import Fuzz exposing (Fuzzer)
|
import Fuzz exposing (Fuzzer)
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
import Internal.Values.Vault exposing (Vault)
|
import Internal.Values.Vault exposing (Vault)
|
||||||
import Test exposing (..)
|
import Test exposing (..)
|
||||||
import Test.Tools.Hashdict as TestHashdict
|
import Test.Tools.Hashdict as TestHashdict
|
||||||
import Test.Values.Room as TestRoom
|
import Test.Values.Room as TestRoom
|
||||||
import Test.Values.User as TestUser
|
|
||||||
|
|
||||||
|
|
||||||
vault : Fuzzer Vault
|
vault : Fuzzer Vault
|
||||||
vault =
|
vault =
|
||||||
Fuzz.map3 Vault
|
Fuzz.map2 Vault
|
||||||
(Fuzz.string
|
(Fuzz.string
|
||||||
|> Fuzz.map (\k -> ( k, Json.encode Json.int 0 ))
|
|> Fuzz.map (\k -> ( k, Json.encode Json.int 0 ))
|
||||||
|> Fuzz.list
|
|> Fuzz.list
|
||||||
|> Fuzz.map Dict.fromList
|
|> Fuzz.map Dict.fromList
|
||||||
)
|
)
|
||||||
(TestHashdict.fuzzer .roomId TestRoom.fuzzer)
|
(TestHashdict.fuzzer .roomId TestRoom.fuzzer)
|
||||||
TestUser.fuzzer
|
|
||||||
|
|
Loading…
Reference in New Issue