Rename CredUpdate -> VaultUpdate
parent
e90f823000
commit
10903b0e05
|
@ -14,18 +14,18 @@ submodule, this can lead to indentation hell.
|
||||||
This module aims to allow for simple task chaining without adding too much complexity
|
This module aims to allow for simple task chaining without adding too much complexity
|
||||||
if you wish to pass on values.
|
if you wish to pass on values.
|
||||||
|
|
||||||
The model is like a snake: _____
|
The model is like a snake: \_\_\_\_\_
|
||||||
/ o \
|
/ o \\
|
||||||
/-|------------ | ------- | ------------- | -------- | |\/\/
|
/-|------------ | ------- | ------------- | -------- | |//
|
||||||
< | accessToken | baseUrl | transactionId | API call | |------< Final API call
|
< | accessToken | baseUrl | transactionId | API call | |------< Final API call
|
||||||
\-|------------ | ------- | ------------- | -------- | |/\/\
|
-|------------ | ------- | ------------- | -------- | |//\\
|
||||||
\-----/
|
-----/
|
||||||
|
|
||||||
(You're not allowed to judge my ASCII art skills unless you submit a PR with a
|
(You're not allowed to judge my ASCII art skills unless you submit a PR with a
|
||||||
superior ASCII snake model.)
|
superior ASCII snake model.)
|
||||||
|
|
||||||
Every task will add another value to an extensible record, which can be used
|
Every task will add another value to an extensible record, which can be used
|
||||||
by later tasks in the chain. Additionally, every subtask can leave a `CredUpdate`
|
by later tasks in the chain. Additionally, every subtask can leave a `VaultUpdate`
|
||||||
type as a message to the Credentials to update certain information.
|
type as a message to the Credentials to update certain information.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
module Internal.Api.GetEvent.Main exposing (..)
|
module Internal.Api.GetEvent.Main exposing (..)
|
||||||
|
|
||||||
import Internal.Api.GetEvent.Api as Api
|
import Internal.Api.GetEvent.Api as Api
|
||||||
|
import Internal.Tools.Context as Context exposing (Context, VBA)
|
||||||
import Internal.Tools.Exceptions as X
|
import Internal.Tools.Exceptions as X
|
||||||
import Internal.Tools.VersionControl as VC
|
import Internal.Tools.VersionControl as VC
|
||||||
import Task exposing (Task)
|
import Task exposing (Task)
|
||||||
|
|
||||||
|
|
||||||
getEvent : List String -> EventInput -> Task X.Error EventOutput
|
getEvent : Context (VBA a) -> EventInput -> Task X.Error EventOutput
|
||||||
getEvent versions =
|
getEvent context input =
|
||||||
VC.withBottomLayer
|
VC.withBottomLayer
|
||||||
{ current = Api.getEventInputV1
|
{ current = Api.getEventInputV1
|
||||||
, version = "r0.5.0"
|
, version = "r0.5.0"
|
||||||
|
@ -19,8 +20,10 @@ getEvent versions =
|
||||||
|> VC.sameForVersion "v1.3"
|
|> VC.sameForVersion "v1.3"
|
||||||
|> VC.sameForVersion "v1.4"
|
|> VC.sameForVersion "v1.4"
|
||||||
|> VC.sameForVersion "v1.5"
|
|> VC.sameForVersion "v1.5"
|
||||||
|> VC.mostRecentFromVersionList versions
|
|> VC.mostRecentFromVersionList (Context.getVersions context)
|
||||||
|> Maybe.withDefault (always <| Task.fail X.UnsupportedSpecVersion)
|
|> Maybe.withDefault (always <| always <| Task.fail X.UnsupportedSpecVersion)
|
||||||
|
|> (|>) input
|
||||||
|
|> (|>) context
|
||||||
|
|
||||||
|
|
||||||
type alias EventOutput =
|
type alias EventOutput =
|
||||||
|
|
|
@ -18,7 +18,9 @@ sync context input =
|
||||||
|> VC.addMiddleLayer
|
|> VC.addMiddleLayer
|
||||||
{ current = Api.syncV2
|
{ current = Api.syncV2
|
||||||
, downcast = identity
|
, downcast = identity
|
||||||
, upcast = Task.map U2.upcastSync
|
, upcast =
|
||||||
|
\f c ->
|
||||||
|
Task.map U2.upcastSync (f c)
|
||||||
, version = "v1.4"
|
, version = "v1.4"
|
||||||
}
|
}
|
||||||
|> VC.sameForVersion "v1.5"
|
|> VC.sameForVersion "v1.5"
|
||||||
|
|
|
@ -5,8 +5,13 @@ module Internal.Api.Task exposing (..)
|
||||||
|
|
||||||
import Hash
|
import Hash
|
||||||
import Internal.Api.Chain as Chain
|
import Internal.Api.Chain as Chain
|
||||||
import Internal.Api.CredUpdate as C
|
|
||||||
import Internal.Api.Credentials exposing (Credentials)
|
import Internal.Api.Credentials exposing (Credentials)
|
||||||
|
import Internal.Api.GetEvent.Main exposing (EventInput)
|
||||||
|
import Internal.Api.Invite.Main exposing (InviteInput)
|
||||||
|
import Internal.Api.JoinedMembers.Main exposing (JoinedMembersInput)
|
||||||
|
import Internal.Api.SendStateKey.Main exposing (SendStateKeyInput)
|
||||||
|
import Internal.Api.Sync.Main exposing (SyncInput)
|
||||||
|
import Internal.Api.VaultUpdate as C
|
||||||
import Json.Encode as E
|
import Json.Encode as E
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,21 +19,21 @@ type alias FutureTask =
|
||||||
C.FutureTask
|
C.FutureTask
|
||||||
|
|
||||||
|
|
||||||
getEvent : C.GetEventInput -> Credentials -> FutureTask
|
getEvent : EventInput -> Credentials -> FutureTask
|
||||||
getEvent data cred =
|
getEvent data cred =
|
||||||
C.makeVBA cred
|
C.makeVBA cred
|
||||||
|> Chain.andThen (C.getEvent data)
|
|> Chain.andThen (C.getEvent data)
|
||||||
|> C.toTask
|
|> C.toTask
|
||||||
|
|
||||||
|
|
||||||
invite : C.InviteInput -> Credentials -> FutureTask
|
invite : InviteInput -> Credentials -> FutureTask
|
||||||
invite data cred =
|
invite data cred =
|
||||||
C.makeVBA cred
|
C.makeVBA cred
|
||||||
|> Chain.andThen (C.invite data)
|
|> Chain.andThen (C.invite data)
|
||||||
|> C.toTask
|
|> C.toTask
|
||||||
|
|
||||||
|
|
||||||
joinedMembers : C.JoinedMembersInput -> Credentials -> FutureTask
|
joinedMembers : JoinedMembersInput -> Credentials -> FutureTask
|
||||||
joinedMembers data cred =
|
joinedMembers data cred =
|
||||||
C.makeVBA cred
|
C.makeVBA cred
|
||||||
|> Chain.andThen (C.joinedMembers data)
|
|> Chain.andThen (C.joinedMembers data)
|
||||||
|
@ -90,15 +95,15 @@ sendMessageEvent { content, eventType, extraTransactionNoise, roomId } cred =
|
||||||
|> C.toTask
|
|> C.toTask
|
||||||
|
|
||||||
|
|
||||||
sendStateKey : C.SendStateEventInput -> Credentials -> FutureTask
|
sendStateEvent : SendStateKeyInput -> Credentials -> FutureTask
|
||||||
sendStateKey data cred =
|
sendStateEvent data cred =
|
||||||
C.makeVBA cred
|
C.makeVBA cred
|
||||||
|> Chain.andThen (C.sendStateEvent data)
|
|> Chain.andThen (C.sendStateEvent data)
|
||||||
-- TODO: Get event from API to see what it looks like
|
-- TODO: Get event from API to see what it looks like
|
||||||
|> C.toTask
|
|> C.toTask
|
||||||
|
|
||||||
|
|
||||||
sync : C.SyncInput -> Credentials -> FutureTask
|
sync : SyncInput -> Credentials -> FutureTask
|
||||||
sync data cred =
|
sync data cred =
|
||||||
C.makeVBA cred
|
C.makeVBA cred
|
||||||
|> Chain.andThen (C.sync data)
|
|> Chain.andThen (C.sync data)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module Internal.Api.CredUpdate exposing (..)
|
module Internal.Api.VaultUpdate exposing (..)
|
||||||
|
|
||||||
import Internal.Api.Chain as Chain exposing (IdemChain, TaskChain)
|
import Internal.Api.Chain as Chain exposing (IdemChain, TaskChain)
|
||||||
import Internal.Api.Credentials as Credentials exposing (Credentials)
|
import Internal.Api.Credentials as Credentials exposing (Credentials)
|
||||||
|
@ -15,14 +15,12 @@ import Internal.Api.Versions.V1.Versions as V
|
||||||
import Internal.Tools.Context as Context exposing (VB, VBA, VBAT)
|
import Internal.Tools.Context as Context exposing (VB, VBA, VBAT)
|
||||||
import Internal.Tools.Exceptions as X
|
import Internal.Tools.Exceptions as X
|
||||||
import Internal.Tools.LoginValues exposing (AccessToken(..))
|
import Internal.Tools.LoginValues exposing (AccessToken(..))
|
||||||
import Internal.Tools.SpecEnums as Enums
|
|
||||||
import Json.Encode as E
|
|
||||||
import Task exposing (Task)
|
import Task exposing (Task)
|
||||||
import Time
|
import Time
|
||||||
|
|
||||||
|
|
||||||
type CredUpdate
|
type VaultUpdate
|
||||||
= MultipleUpdates (List CredUpdate)
|
= MultipleUpdates (List VaultUpdate)
|
||||||
-- Updates as a result of API calls
|
-- Updates as a result of API calls
|
||||||
| GetEvent GetEvent.EventInput GetEvent.EventOutput
|
| GetEvent GetEvent.EventInput GetEvent.EventOutput
|
||||||
| InviteSent Invite.InviteInput Invite.InviteOutput
|
| InviteSent Invite.InviteInput Invite.InviteOutput
|
||||||
|
@ -38,12 +36,12 @@ type CredUpdate
|
||||||
|
|
||||||
|
|
||||||
type alias FutureTask =
|
type alias FutureTask =
|
||||||
Task X.Error CredUpdate
|
Task X.Error VaultUpdate
|
||||||
|
|
||||||
|
|
||||||
{-| Turn an API Task into a taskchain.
|
{-| Turn an API Task into a taskchain.
|
||||||
-}
|
-}
|
||||||
toChain : (cout -> Chain.TaskChainPiece CredUpdate ph1 ph2) -> (Context.Context ph1 -> cin -> Task X.Error cout) -> cin -> TaskChain CredUpdate ph1 ph2
|
toChain : (cout -> Chain.TaskChainPiece VaultUpdate ph1 ph2) -> (Context.Context ph1 -> cin -> Task X.Error cout) -> cin -> TaskChain VaultUpdate ph1 ph2
|
||||||
toChain transform task input context =
|
toChain transform task input context =
|
||||||
task context input
|
task context input
|
||||||
|> Task.map transform
|
|> Task.map transform
|
||||||
|
@ -51,7 +49,7 @@ toChain transform task input context =
|
||||||
|
|
||||||
{-| Turn a chain of tasks into a full executable task.
|
{-| Turn a chain of tasks into a full executable task.
|
||||||
-}
|
-}
|
||||||
toTask : TaskChain CredUpdate {} b -> FutureTask
|
toTask : TaskChain VaultUpdate {} b -> FutureTask
|
||||||
toTask =
|
toTask =
|
||||||
Chain.toTask
|
Chain.toTask
|
||||||
>> Task.map
|
>> Task.map
|
||||||
|
@ -67,7 +65,7 @@ toTask =
|
||||||
|
|
||||||
{-| Get a functional access token.
|
{-| Get a functional access token.
|
||||||
-}
|
-}
|
||||||
accessToken : AccessToken -> TaskChain CredUpdate (VB a) (VBA a)
|
accessToken : AccessToken -> TaskChain VaultUpdate (VB a) (VBA a)
|
||||||
accessToken ctoken =
|
accessToken ctoken =
|
||||||
case ctoken of
|
case ctoken of
|
||||||
NoAccess ->
|
NoAccess ->
|
||||||
|
@ -96,7 +94,7 @@ accessToken ctoken =
|
||||||
|
|
||||||
{-| Get an event from the API.
|
{-| Get an event from the API.
|
||||||
-}
|
-}
|
||||||
getEvent : GetEvent.EventInput -> IdemChain CredUpdate (VBA a)
|
getEvent : GetEvent.EventInput -> IdemChain VaultUpdate (VBA a)
|
||||||
getEvent input =
|
getEvent input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -111,7 +109,7 @@ getEvent input =
|
||||||
|
|
||||||
{-| Get the supported spec versions from the homeserver.
|
{-| Get the supported spec versions from the homeserver.
|
||||||
-}
|
-}
|
||||||
getVersions : TaskChain CredUpdate { a | baseUrl : () } (VB a)
|
getVersions : TaskChain VaultUpdate { a | baseUrl : () } (VB a)
|
||||||
getVersions =
|
getVersions =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -126,7 +124,7 @@ getVersions =
|
||||||
|
|
||||||
{-| Invite a user to a room.
|
{-| Invite a user to a room.
|
||||||
-}
|
-}
|
||||||
invite : Invite.InviteInput -> IdemChain CredUpdate (VBA a)
|
invite : Invite.InviteInput -> IdemChain VaultUpdate (VBA a)
|
||||||
invite input =
|
invite input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -139,7 +137,7 @@ invite input =
|
||||||
input
|
input
|
||||||
|
|
||||||
|
|
||||||
joinedMembers : JoinedMembers.JoinedMembersInput -> IdemChain CredUpdate (VBA a)
|
joinedMembers : JoinedMembers.JoinedMembersInput -> IdemChain VaultUpdate (VBA a)
|
||||||
joinedMembers input =
|
joinedMembers input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -152,7 +150,7 @@ joinedMembers input =
|
||||||
input
|
input
|
||||||
|
|
||||||
|
|
||||||
loginWithUsernameAndPassword : LoginWithUsernameAndPassword.LoginWithUsernameAndPasswordInput -> TaskChain CredUpdate (VB a) (VBA a)
|
loginWithUsernameAndPassword : LoginWithUsernameAndPassword.LoginWithUsernameAndPasswordInput -> TaskChain VaultUpdate (VB a) (VBA a)
|
||||||
loginWithUsernameAndPassword input =
|
loginWithUsernameAndPassword input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -171,7 +169,7 @@ loginWithUsernameAndPassword input =
|
||||||
|
|
||||||
{-| Make a VB-context based chain.
|
{-| Make a VB-context based chain.
|
||||||
-}
|
-}
|
||||||
makeVB : Credentials -> TaskChain CredUpdate {} (VB {})
|
makeVB : Credentials -> TaskChain VaultUpdate {} (VB {})
|
||||||
makeVB cred =
|
makeVB cred =
|
||||||
cred
|
cred
|
||||||
|> Credentials.baseUrl
|
|> Credentials.baseUrl
|
||||||
|
@ -181,7 +179,7 @@ makeVB cred =
|
||||||
|
|
||||||
{-| Make a VBA-context based chain.
|
{-| Make a VBA-context based chain.
|
||||||
-}
|
-}
|
||||||
makeVBA : Credentials -> TaskChain CredUpdate {} (VBA {})
|
makeVBA : Credentials -> TaskChain VaultUpdate {} (VBA {})
|
||||||
makeVBA cred =
|
makeVBA cred =
|
||||||
cred
|
cred
|
||||||
|> makeVB
|
|> makeVB
|
||||||
|
@ -190,7 +188,7 @@ makeVBA cred =
|
||||||
|
|
||||||
{-| Make a VBAT-context based chain.
|
{-| Make a VBAT-context based chain.
|
||||||
-}
|
-}
|
||||||
makeVBAT : (Int -> String) -> Credentials -> TaskChain CredUpdate {} (VBAT {})
|
makeVBAT : (Int -> String) -> Credentials -> TaskChain VaultUpdate {} (VBAT {})
|
||||||
makeVBAT toString cred =
|
makeVBAT toString cred =
|
||||||
cred
|
cred
|
||||||
|> makeVBA
|
|> makeVBA
|
||||||
|
@ -199,7 +197,7 @@ makeVBAT toString cred =
|
||||||
|
|
||||||
{-| Redact an event from a room.
|
{-| Redact an event from a room.
|
||||||
-}
|
-}
|
||||||
redact : Redact.RedactInput -> TaskChain CredUpdate (VBAT a) (VBA a)
|
redact : Redact.RedactInput -> TaskChain VaultUpdate (VBAT a) (VBA a)
|
||||||
redact input =
|
redact input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -214,7 +212,7 @@ redact input =
|
||||||
|
|
||||||
{-| Send a message event to a room.
|
{-| Send a message event to a room.
|
||||||
-}
|
-}
|
||||||
sendMessageEvent : SendMessageEvent.SendMessageEventInput -> TaskChain CredUpdate (VBAT a) (VBA a)
|
sendMessageEvent : SendMessageEvent.SendMessageEventInput -> TaskChain VaultUpdate (VBAT a) (VBA a)
|
||||||
sendMessageEvent input =
|
sendMessageEvent input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -229,7 +227,7 @@ sendMessageEvent input =
|
||||||
|
|
||||||
{-| Send a state key event to a room.
|
{-| Send a state key event to a room.
|
||||||
-}
|
-}
|
||||||
sendStateEvent : SendStateKey.SendStateKeyInput -> IdemChain CredUpdate (VBA a)
|
sendStateEvent : SendStateKey.SendStateKeyInput -> IdemChain VaultUpdate (VBA a)
|
||||||
sendStateEvent input =
|
sendStateEvent input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -244,7 +242,7 @@ sendStateEvent input =
|
||||||
|
|
||||||
{-| Sync the latest updates.
|
{-| Sync the latest updates.
|
||||||
-}
|
-}
|
||||||
sync : Sync.SyncInput -> IdemChain CredUpdate (VBA a)
|
sync : Sync.SyncInput -> IdemChain VaultUpdate (VBA a)
|
||||||
sync input =
|
sync input =
|
||||||
toChain
|
toChain
|
||||||
(\output ->
|
(\output ->
|
||||||
|
@ -259,7 +257,7 @@ sync input =
|
||||||
|
|
||||||
{-| Insert versions, or get them if they are not provided.
|
{-| Insert versions, or get them if they are not provided.
|
||||||
-}
|
-}
|
||||||
versions : Maybe V.Versions -> TaskChain CredUpdate { a | baseUrl : () } (VB a)
|
versions : Maybe V.Versions -> TaskChain VaultUpdate { a | baseUrl : () } (VB a)
|
||||||
versions mVersions =
|
versions mVersions =
|
||||||
case mVersions of
|
case mVersions of
|
||||||
Just vs ->
|
Just vs ->
|
||||||
|
@ -271,7 +269,7 @@ versions mVersions =
|
||||||
|
|
||||||
{-| Create a task that insert the base URL into the context.
|
{-| Create a task that insert the base URL into the context.
|
||||||
-}
|
-}
|
||||||
withBaseUrl : String -> TaskChain CredUpdate a { a | baseUrl : () }
|
withBaseUrl : String -> TaskChain VaultUpdate a { a | baseUrl : () }
|
||||||
withBaseUrl baseUrl =
|
withBaseUrl baseUrl =
|
||||||
{ contextChange = Context.setBaseUrl baseUrl
|
{ contextChange = Context.setBaseUrl baseUrl
|
||||||
, messages = []
|
, messages = []
|
||||||
|
@ -283,7 +281,7 @@ withBaseUrl baseUrl =
|
||||||
|
|
||||||
{-| Create a task that inserts a transaction id into the context.
|
{-| Create a task that inserts a transaction id into the context.
|
||||||
-}
|
-}
|
||||||
withTransactionId : (Int -> String) -> TaskChain CredUpdate a { a | transactionId : () }
|
withTransactionId : (Int -> String) -> TaskChain VaultUpdate a { a | transactionId : () }
|
||||||
withTransactionId toString =
|
withTransactionId toString =
|
||||||
Time.now
|
Time.now
|
||||||
|> Task.map
|
|> Task.map
|
||||||
|
@ -302,7 +300,7 @@ withTransactionId toString =
|
||||||
|
|
||||||
{-| Create a task that inserts versions into the context.
|
{-| Create a task that inserts versions into the context.
|
||||||
-}
|
-}
|
||||||
withVersions : V.Versions -> TaskChain CredUpdate { a | baseUrl : () } (VB a)
|
withVersions : V.Versions -> TaskChain VaultUpdate { a | baseUrl : () } (VB a)
|
||||||
withVersions vs =
|
withVersions vs =
|
||||||
{ contextChange = Context.setVersions vs.versions
|
{ contextChange = Context.setVersions vs.versions
|
||||||
, messages = []
|
, messages = []
|
|
@ -4,10 +4,10 @@ module Internal.Room exposing (..)
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Dict
|
import Dict
|
||||||
import Internal.Api.CredUpdate exposing (CredUpdate)
|
|
||||||
import Internal.Api.Credentials as Credentials exposing (Credentials)
|
import Internal.Api.Credentials as Credentials exposing (Credentials)
|
||||||
import Internal.Api.Sync.V2.SpecObjects as Sync
|
import Internal.Api.Sync.V2.SpecObjects as Sync
|
||||||
import Internal.Api.Task as Api
|
import Internal.Api.Task as Api
|
||||||
|
import Internal.Api.VaultUpdate exposing (VaultUpdate)
|
||||||
import Internal.Event as Event exposing (Event)
|
import Internal.Event as Event exposing (Event)
|
||||||
import Internal.Tools.Exceptions as X
|
import Internal.Tools.Exceptions as X
|
||||||
import Internal.Tools.Hashdict as Hashdict
|
import Internal.Tools.Hashdict as Hashdict
|
||||||
|
@ -136,33 +136,29 @@ roomId =
|
||||||
|
|
||||||
{-| Sends a new event to the Matrix room associated with the given `Room`.
|
{-| Sends a new event to the Matrix room associated with the given `Room`.
|
||||||
-}
|
-}
|
||||||
sendEvent : Room -> { eventType : String, content : E.Value } -> Task X.Error CredUpdate
|
sendEvent : Room -> { eventType : String, content : E.Value } -> Task X.Error VaultUpdate
|
||||||
sendEvent (Room { context, room }) { eventType, content } =
|
sendEvent (Room { context, room }) { eventType, content } =
|
||||||
Api.sendMessageEvent
|
Api.sendMessageEvent
|
||||||
{ accessToken = Credentials.accessToken context
|
{ content = content
|
||||||
, baseUrl = Credentials.baseUrl context
|
|
||||||
, content = content
|
|
||||||
, eventType = eventType
|
, eventType = eventType
|
||||||
, roomId = Internal.roomId room
|
|
||||||
, versions = Credentials.versions context
|
|
||||||
, extraTransactionNoise = "content-value:<object>"
|
, extraTransactionNoise = "content-value:<object>"
|
||||||
|
, roomId = Internal.roomId room
|
||||||
}
|
}
|
||||||
|
context
|
||||||
|
|
||||||
|
|
||||||
{-| Sends a new text message to the Matrix room associated with the given `Room`.
|
{-| Sends a new text message to the Matrix room associated with the given `Room`.
|
||||||
-}
|
-}
|
||||||
sendMessage : Room -> String -> Task X.Error CredUpdate
|
sendMessage : Room -> String -> Task X.Error VaultUpdate
|
||||||
sendMessage (Room { context, room }) text =
|
sendMessage (Room { context, room }) text =
|
||||||
Api.sendMessageEvent
|
Api.sendMessageEvent
|
||||||
{ accessToken = Credentials.accessToken context
|
{ content =
|
||||||
, baseUrl = Credentials.baseUrl context
|
|
||||||
, content =
|
|
||||||
E.object
|
E.object
|
||||||
[ ( "msgtype", E.string "m.text" )
|
[ ( "msgtype", E.string "m.text" )
|
||||||
, ( "body", E.string text )
|
, ( "body", E.string text )
|
||||||
]
|
]
|
||||||
, eventType = "m.room.message"
|
, eventType = "m.room.message"
|
||||||
, roomId = Internal.roomId room
|
|
||||||
, versions = Credentials.versions context
|
|
||||||
, extraTransactionNoise = "literal-message:" ++ text
|
, extraTransactionNoise = "literal-message:" ++ text
|
||||||
|
, roomId = Internal.roomId room
|
||||||
}
|
}
|
||||||
|
context
|
||||||
|
|
|
@ -8,9 +8,9 @@ This file combines the internal functions with the API endpoints to create a ful
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Dict
|
import Dict
|
||||||
import Internal.Api.CredUpdate exposing (CredUpdate(..))
|
|
||||||
import Internal.Api.Credentials as Credentials exposing (Credentials)
|
import Internal.Api.Credentials as Credentials exposing (Credentials)
|
||||||
import Internal.Api.Task as Api
|
import Internal.Api.Task as Api
|
||||||
|
import Internal.Api.VaultUpdate exposing (VaultUpdate(..))
|
||||||
import Internal.Event as Event
|
import Internal.Event as Event
|
||||||
import Internal.Room as Room
|
import Internal.Room as Room
|
||||||
import Internal.Tools.Exceptions as X
|
import Internal.Tools.Exceptions as X
|
||||||
|
@ -88,9 +88,9 @@ insertRoom =
|
||||||
|
|
||||||
{-| Update the Vault type with new values
|
{-| Update the Vault type with new values
|
||||||
-}
|
-}
|
||||||
updateWith : CredUpdate -> Vault -> Vault
|
updateWith : VaultUpdate -> Vault -> Vault
|
||||||
updateWith credUpdate ((Vault ({ cred, context } as data)) as credentials) =
|
updateWith vaultUpdate ((Vault ({ cred, context } as data)) as credentials) =
|
||||||
case credUpdate of
|
case vaultUpdate of
|
||||||
MultipleUpdates updates ->
|
MultipleUpdates updates ->
|
||||||
List.foldl updateWith credentials updates
|
List.foldl updateWith credentials updates
|
||||||
|
|
||||||
|
@ -193,18 +193,16 @@ updateWith credUpdate ((Vault ({ cred, context } as data)) as credentials) =
|
||||||
|
|
||||||
{-| Synchronize credentials
|
{-| Synchronize credentials
|
||||||
-}
|
-}
|
||||||
sync : Vault -> Task X.Error CredUpdate
|
sync : Vault -> Task X.Error VaultUpdate
|
||||||
sync (Vault { cred, context }) =
|
sync (Vault { cred, context }) =
|
||||||
Api.sync
|
Api.sync
|
||||||
{ accessToken = Credentials.accessToken context
|
{ filter = Nothing
|
||||||
, baseUrl = Credentials.baseUrl context
|
|
||||||
, filter = Nothing
|
|
||||||
, fullState = Nothing
|
, fullState = Nothing
|
||||||
, setPresence = Nothing
|
, setPresence = Nothing
|
||||||
, since = Internal.getSince cred
|
, since = Internal.getSince cred
|
||||||
, timeout = Just 30
|
, timeout = Just 30
|
||||||
, versions = Credentials.versions context
|
|
||||||
}
|
}
|
||||||
|
context
|
||||||
|
|
||||||
|
|
||||||
{-| Get a list of all synchronised rooms.
|
{-| Get a list of all synchronised rooms.
|
||||||
|
|
Loading…
Reference in New Issue