elm-format
parent
aa0fe12fb8
commit
d3637cf45f
|
@ -1,4 +1,5 @@
|
|||
module Internal.Api.Context exposing (..)
|
||||
|
||||
{-| This module hosts functions for the `Context` type.
|
||||
|
||||
The `Context` type is a type that is passed along a chain of tasks.
|
||||
|
@ -10,13 +11,15 @@ after having set the value using a setter function.
|
|||
|
||||
Additionaly, there are remove functions which are intended to tell the compiler
|
||||
"you will have to get this value again if you'd like to use it later."
|
||||
|
||||
-}
|
||||
|
||||
import Internal.Config.Leaking as L
|
||||
import Internal.Tools.LoginValues exposing (AccessToken(..))
|
||||
|
||||
type Context a =
|
||||
Context
|
||||
|
||||
type Context a
|
||||
= Context
|
||||
{ accessToken : String
|
||||
, baseUrl : String
|
||||
, transactionId : String
|
||||
|
@ -24,16 +27,25 @@ type Context a =
|
|||
, versions : List String
|
||||
}
|
||||
|
||||
|
||||
type alias UsernameAndPassword =
|
||||
{ username : String, password : String }
|
||||
|
||||
type alias VB a = { a | versions : (), baseUrl : () }
|
||||
|
||||
type alias VBA a = { a | accessToken : (), baseUrl : (), versions : () }
|
||||
type alias VB a =
|
||||
{ a | versions : (), baseUrl : () }
|
||||
|
||||
type alias VBAT a = { a | accessToken : (), baseUrl : (), versions : (), transactionId : () }
|
||||
|
||||
{-| Get a default Context type. -}
|
||||
type alias VBA a =
|
||||
{ a | accessToken : (), baseUrl : (), versions : () }
|
||||
|
||||
|
||||
type alias VBAT a =
|
||||
{ a | accessToken : (), baseUrl : (), versions : (), transactionId : () }
|
||||
|
||||
|
||||
{-| Get a default Context type.
|
||||
-}
|
||||
init : Context {}
|
||||
init =
|
||||
Context
|
||||
|
@ -44,67 +56,93 @@ init =
|
|||
, versions = L.versions
|
||||
}
|
||||
|
||||
{-| Get the access token from the Context. -}
|
||||
|
||||
{-| Get the access token from the Context.
|
||||
-}
|
||||
getAccessToken : Context { a | accessToken : () } -> String
|
||||
getAccessToken (Context { accessToken }) =
|
||||
accessToken
|
||||
|
||||
{-| Get the base url from the Context. -}
|
||||
|
||||
{-| Get the base url from the Context.
|
||||
-}
|
||||
getBaseUrl : Context { a | baseUrl : () } -> String
|
||||
getBaseUrl (Context { baseUrl }) =
|
||||
baseUrl
|
||||
|
||||
{-| Get the transaction id from the Context. -}
|
||||
|
||||
{-| Get the transaction id from the Context.
|
||||
-}
|
||||
getTransactionId : Context { a | transactionId : () } -> String
|
||||
getTransactionId (Context { transactionId }) =
|
||||
transactionId
|
||||
|
||||
{-| Get the username and password of the user, if present. -}
|
||||
|
||||
{-| Get the username and password of the user, if present.
|
||||
-}
|
||||
getUsernameAndPassword : Context { a | accessToken : () } -> Maybe UsernameAndPassword
|
||||
getUsernameAndPassword (Context { usernameAndPassword }) =
|
||||
usernameAndPassword
|
||||
|
||||
{-| Get the supported spec versions from the Context. -}
|
||||
|
||||
{-| Get the supported spec versions from the Context.
|
||||
-}
|
||||
getVersions : Context { a | versions : () } -> List String
|
||||
getVersions (Context { versions }) =
|
||||
versions
|
||||
|
||||
{-| Insert an access token into the context. -}
|
||||
|
||||
{-| Insert an access token into the context.
|
||||
-}
|
||||
setAccessToken : { accessToken : String, usernameAndPassword : Maybe UsernameAndPassword } -> Context a -> Context { a | accessToken : () }
|
||||
setAccessToken { accessToken, usernameAndPassword } (Context data) =
|
||||
Context { data | accessToken = accessToken, usernameAndPassword = usernameAndPassword }
|
||||
|
||||
{-| Insert a base url into the context. -}
|
||||
|
||||
{-| Insert a base url into the context.
|
||||
-}
|
||||
setBaseUrl : String -> Context a -> Context { a | baseUrl : () }
|
||||
setBaseUrl baseUrl (Context data) =
|
||||
Context { data | baseUrl = baseUrl }
|
||||
|
||||
{-| Insert a transaction id into the context. -}
|
||||
|
||||
{-| Insert a transaction id into the context.
|
||||
-}
|
||||
setTransactionId : String -> Context a -> Context { a | transactionId : () }
|
||||
setTransactionId transactionId (Context data) =
|
||||
Context { data | transactionId = transactionId }
|
||||
|
||||
{-| Insert a transaction id into the context. -}
|
||||
|
||||
{-| Insert a transaction id into the context.
|
||||
-}
|
||||
setVersions : List String -> Context a -> Context { a | versions : () }
|
||||
setVersions versions (Context data) =
|
||||
Context { data | versions = versions }
|
||||
|
||||
{-| Remove the access token from the Context -}
|
||||
|
||||
{-| Remove the access token from the Context
|
||||
-}
|
||||
removeAccessToken : Context { a | accessToken : () } -> Context a
|
||||
removeAccessToken (Context data) =
|
||||
Context data
|
||||
|
||||
{-| Remove the base url from the Context -}
|
||||
|
||||
{-| Remove the base url from the Context
|
||||
-}
|
||||
removeBaseUrl : Context { a | baseUrl : () } -> Context a
|
||||
removeBaseUrl (Context data) =
|
||||
Context data
|
||||
|
||||
{-| Remove the transaction id from the Context -}
|
||||
|
||||
{-| Remove the transaction id from the Context
|
||||
-}
|
||||
removeTransactionId : Context { a | transactionId : () } -> Context a
|
||||
removeTransactionId (Context data) =
|
||||
Context data
|
||||
|
||||
{-| Remove the versions from the Context -}
|
||||
|
||||
{-| Remove the versions from the Context
|
||||
-}
|
||||
removeVersions : Context { a | versions : () } -> Context a
|
||||
removeVersions (Context data) =
|
||||
Context data
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
module Internal.Api.CredUpdate exposing (..)
|
||||
|
||||
import Hash
|
||||
import Internal.Api.Chain as Chain exposing (TaskChain, IdemChain)
|
||||
import Html exposing (input)
|
||||
import Internal.Api.Chain as Chain exposing (IdemChain, TaskChain)
|
||||
import Internal.Api.Context as Context exposing (VB, VBA, VBAT)
|
||||
import Internal.Api.GetEvent.Main as GetEvent
|
||||
import Internal.Api.Invite.Main as Invite
|
||||
import Internal.Api.JoinedMembers.Main as JoinedMembers
|
||||
import Internal.Api.LoginWithUsernameAndPassword.Main as LoginWithUsernameAndPassword
|
||||
import Internal.Api.Versions.V1.Versions as V
|
||||
import Internal.Api.Redact.Main as Redact
|
||||
import Internal.Api.SendMessageEvent.Main as SendMessageEvent
|
||||
import Internal.Api.SendStateKey.Main as SendStateKey
|
||||
import Internal.Api.Sync.Main as Sync
|
||||
import Internal.Api.Versions.Main as Versions
|
||||
import Internal.Api.Versions.V1.Versions as V
|
||||
import Internal.Tools.Exceptions as X
|
||||
import Internal.Tools.LoginValues exposing (AccessToken(..))
|
||||
import Internal.Tools.SpecEnums as Enums
|
||||
import Json.Encode as E
|
||||
import Task exposing (Task)
|
||||
import Time
|
||||
import Html exposing (input)
|
||||
|
||||
|
||||
type CredUpdate
|
||||
|
@ -37,7 +37,10 @@ type CredUpdate
|
|||
| UpdateAccessToken String
|
||||
| UpdateVersions V.Versions
|
||||
|
||||
type alias FutureTask = Task X.Error CredUpdate
|
||||
|
||||
type alias FutureTask =
|
||||
Task X.Error CredUpdate
|
||||
|
||||
|
||||
{-| Turn a chain of tasks into a full executable task.
|
||||
-}
|
||||
|
@ -54,6 +57,7 @@ toTask =
|
|||
MultipleUpdates updates
|
||||
)
|
||||
|
||||
|
||||
{-| Get a functional access token.
|
||||
-}
|
||||
accessToken : AccessToken -> TaskChain CredUpdate (VB a) (VBA a)
|
||||
|
@ -82,15 +86,18 @@ accessToken ctoken =
|
|||
loginWithUsernameAndPassword
|
||||
{ username = username, password = password }
|
||||
|
||||
|
||||
type alias GetEventInput =
|
||||
{ eventId : String, roomId : String }
|
||||
|
||||
|
||||
{-| Get an event from the API.
|
||||
-}
|
||||
getEvent : GetEventInput -> IdemChain CredUpdate (VBA a)
|
||||
getEvent { eventId, roomId } context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, eventId = eventId
|
||||
, roomId = roomId
|
||||
|
@ -98,19 +105,22 @@ getEvent { eventId, roomId } context =
|
|||
in
|
||||
input
|
||||
|> GetEvent.getEvent (Context.getVersions context)
|
||||
|> Task.map (\output ->
|
||||
|> Task.map
|
||||
(\output ->
|
||||
Chain.TaskChainPiece
|
||||
{ contextChange = identity
|
||||
, messages = [ GetEvent input output ]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
{-| Get the supported spec versions from the homeserver.
|
||||
-}
|
||||
getVersions : TaskChain CredUpdate { a | baseUrl : () } (VB a)
|
||||
getVersions context =
|
||||
let
|
||||
input = Context.getBaseUrl context
|
||||
input =
|
||||
Context.getBaseUrl context
|
||||
in
|
||||
Versions.getVersions input
|
||||
|> Task.map
|
||||
|
@ -121,17 +131,21 @@ getVersions context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias InviteInput =
|
||||
{ reason : Maybe String
|
||||
, roomId : String
|
||||
, userId : String
|
||||
}
|
||||
|
||||
{-| Invite a user to a room. -}
|
||||
|
||||
{-| Invite a user to a room.
|
||||
-}
|
||||
invite : InviteInput -> IdemChain CredUpdate (VBA a)
|
||||
invite { reason, roomId, userId } context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, reason = reason
|
||||
, roomId = roomId
|
||||
|
@ -148,13 +162,16 @@ invite { reason, roomId, userId } context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias JoinedMembersInput =
|
||||
{ roomId : String }
|
||||
|
||||
|
||||
joinedMembers : JoinedMembersInput -> IdemChain CredUpdate (VBA a)
|
||||
joinedMembers { roomId } context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, roomId = roomId
|
||||
}
|
||||
|
@ -169,15 +186,18 @@ joinedMembers { roomId } context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias LoginWithUsernameAndPasswordInput =
|
||||
{ password : String
|
||||
, username : String
|
||||
}
|
||||
|
||||
|
||||
loginWithUsernameAndPassword : LoginWithUsernameAndPasswordInput -> TaskChain CredUpdate (VB a) (VBA a)
|
||||
loginWithUsernameAndPassword ({ username, password } as data) context =
|
||||
let
|
||||
input = { baseUrl = Context.getBaseUrl context
|
||||
input =
|
||||
{ baseUrl = Context.getBaseUrl context
|
||||
, username = username
|
||||
, password = password
|
||||
}
|
||||
|
@ -196,18 +216,21 @@ loginWithUsernameAndPassword ({ username, password } as data) context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias RedactInput =
|
||||
{ eventId : String
|
||||
, reason : Maybe String
|
||||
, roomId : String
|
||||
}
|
||||
|
||||
|
||||
{-| Redact an event from a room.
|
||||
-}
|
||||
redact : RedactInput -> TaskChain CredUpdate (VBAT a) (VBA a)
|
||||
redact { eventId, reason, roomId } context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, eventId = eventId
|
||||
, reason = reason
|
||||
|
@ -225,18 +248,21 @@ redact { eventId, reason, roomId } context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias SendMessageEventInput =
|
||||
{ content : E.Value
|
||||
, eventType : String
|
||||
, roomId : String
|
||||
}
|
||||
|
||||
|
||||
{-| Send a message event to a room.
|
||||
-}
|
||||
sendMessageEvent : SendMessageEventInput -> TaskChain CredUpdate (VBAT a) (VBA a)
|
||||
sendMessageEvent { content, eventType, roomId } context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, content = content
|
||||
, eventType = eventType
|
||||
|
@ -254,6 +280,7 @@ sendMessageEvent { content, eventType, roomId } context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias SendStateEventInput =
|
||||
{ content : E.Value
|
||||
, eventType : String
|
||||
|
@ -261,12 +288,14 @@ type alias SendStateEventInput =
|
|||
, stateKey : String
|
||||
}
|
||||
|
||||
|
||||
{-| Send a state key event to a room.
|
||||
-}
|
||||
sendStateEvent : SendStateEventInput -> IdemChain CredUpdate (VBA a)
|
||||
sendStateEvent { content, eventType, roomId, stateKey } context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, content = content
|
||||
, eventType = eventType
|
||||
|
@ -284,6 +313,7 @@ sendStateEvent { content, eventType, roomId, stateKey } context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
type alias SyncInput =
|
||||
{ filter : Maybe String
|
||||
, fullState : Maybe Bool
|
||||
|
@ -292,12 +322,14 @@ type alias SyncInput =
|
|||
, timeout : Maybe Int
|
||||
}
|
||||
|
||||
|
||||
{-| Sync the latest updates.
|
||||
-}
|
||||
sync : SyncInput -> IdemChain CredUpdate (VBA a)
|
||||
sync data context =
|
||||
let
|
||||
input = { accessToken = Context.getAccessToken context
|
||||
input =
|
||||
{ accessToken = Context.getAccessToken context
|
||||
, baseUrl = Context.getBaseUrl context
|
||||
, filter = data.filter
|
||||
, fullState = data.fullState
|
||||
|
@ -316,6 +348,7 @@ sync data context =
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
{-| Insert versions, or get them if they are not provided.
|
||||
-}
|
||||
versions : Maybe V.Versions -> TaskChain CredUpdate { a | baseUrl : () } (VB a)
|
||||
|
@ -327,6 +360,7 @@ versions mVersions =
|
|||
Nothing ->
|
||||
getVersions
|
||||
|
||||
|
||||
{-| Create a task that insert the base URL into the context.
|
||||
-}
|
||||
withBaseUrl : String -> TaskChain CredUpdate a { a | baseUrl : () }
|
||||
|
@ -338,6 +372,7 @@ withBaseUrl baseUrl =
|
|||
|> Task.succeed
|
||||
|> always
|
||||
|
||||
|
||||
{-| Create a task that inserts a transaction id into the context.
|
||||
-}
|
||||
withTransactionId : (Int -> String) -> TaskChain CredUpdate a { a | transactionId : () }
|
||||
|
@ -356,6 +391,7 @@ withTransactionId toString =
|
|||
)
|
||||
|> always
|
||||
|
||||
|
||||
{-| Create a task that inserts versions into the context.
|
||||
-}
|
||||
withVersions : V.Versions -> TaskChain CredUpdate { a | baseUrl : () } (VB a)
|
||||
|
|
|
@ -5,6 +5,7 @@ import Internal.Tools.Exceptions as X
|
|||
import Json.Decode as D
|
||||
import Task exposing (Task)
|
||||
|
||||
|
||||
type alias InviteInputV1 =
|
||||
{ accessToken : String
|
||||
, baseUrl : String
|
||||
|
@ -12,6 +13,7 @@ type alias InviteInputV1 =
|
|||
, userId : String
|
||||
}
|
||||
|
||||
|
||||
type alias InviteInputV2 =
|
||||
{ accessToken : String
|
||||
, baseUrl : String
|
||||
|
@ -20,7 +22,10 @@ type alias InviteInputV2 =
|
|||
, userId : String
|
||||
}
|
||||
|
||||
type alias InviteOutputV1 = ()
|
||||
|
||||
type alias InviteOutputV1 =
|
||||
()
|
||||
|
||||
|
||||
inviteV1 : InviteInputV1 -> Task X.Error InviteOutputV1
|
||||
inviteV1 data =
|
||||
|
@ -40,6 +45,7 @@ inviteV1 data =
|
|||
, decoder = always (D.map (always ()) D.value)
|
||||
}
|
||||
|
||||
|
||||
inviteV2 : InviteInputV2 -> Task X.Error InviteOutputV1
|
||||
inviteV2 data =
|
||||
R.rawApiCall
|
||||
|
|
|
@ -22,13 +22,12 @@ invite versions =
|
|||
|> VC.sameForVersion "r0.6.1"
|
||||
|> VC.addMiddleLayer
|
||||
{ downcast =
|
||||
(\data ->
|
||||
\data ->
|
||||
{ accessToken = data.accessToken
|
||||
, baseUrl = data.baseUrl
|
||||
, roomId = data.roomId
|
||||
, userId = data.userId
|
||||
}
|
||||
)
|
||||
, current = Api.inviteV2
|
||||
, upcast = identity
|
||||
, version = "v1.1"
|
||||
|
@ -40,8 +39,10 @@ invite versions =
|
|||
|> VC.mostRecentFromVersionList versions
|
||||
|> Maybe.withDefault (always <| Task.fail X.UnsupportedSpecVersion)
|
||||
|
||||
|
||||
type alias InviteInput =
|
||||
Api.InviteInputV2
|
||||
|
||||
|
||||
type alias InviteOutput =
|
||||
Api.InviteOutputV1
|
||||
|
|
|
@ -6,12 +6,14 @@ import Internal.Tools.Exceptions as X
|
|||
import Json.Encode as E
|
||||
import Task exposing (Task)
|
||||
|
||||
|
||||
type alias LoginWithUsernameAndPasswordInputV1 =
|
||||
{ baseUrl : String
|
||||
, password : String
|
||||
, username : String
|
||||
}
|
||||
|
||||
|
||||
type alias LoginWithUsernameAndPasswordOutputV1 =
|
||||
SO.LoggedInResponse
|
||||
|
||||
|
@ -37,4 +39,3 @@ loginWithUsernameAndPasswordV1 data =
|
|||
, timeout = Nothing
|
||||
, decoder = always SO.loggedInResponseDecoder
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import Internal.Tools.Exceptions as X
|
|||
import Internal.Tools.VersionControl as VC
|
||||
import Task exposing (Task)
|
||||
|
||||
|
||||
loginWithUsernameAndPassword : List String -> LoginWithUsernameAndPasswordInput -> Task X.Error LoginWithUsernameAndPasswordOutput
|
||||
loginWithUsernameAndPassword versions =
|
||||
VC.withBottomLayer
|
||||
|
@ -18,6 +19,6 @@ loginWithUsernameAndPassword versions =
|
|||
type alias LoginWithUsernameAndPasswordInput =
|
||||
Api.LoginWithUsernameAndPasswordInputV1
|
||||
|
||||
|
||||
type alias LoginWithUsernameAndPasswordOutput =
|
||||
Api.LoginWithUsernameAndPasswordOutputV1
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ that the credentials type needs to know about before it can make a request.
|
|||
-}
|
||||
|
||||
import Internal.Api.LoginWithUsernameAndPassword.V1.Login as L
|
||||
import Internal.Api.Versions.V1.Versions as V
|
||||
import Internal.Api.Request as R
|
||||
import Internal.Api.Versions.V1.Versions as V
|
||||
import Internal.Tools.Exceptions as X
|
||||
import Internal.Tools.LoginValues exposing (AccessToken(..))
|
||||
import Internal.Tools.ValueGetter exposing (ValueGetter)
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
module Internal.Api.Task exposing (..)
|
||||
|
||||
{-| This module contains all tasks that can be executed.
|
||||
-}
|
||||
|
||||
import Hash
|
||||
import Internal.Api.CredUpdate as C exposing (CredUpdate)
|
||||
import Internal.Api.Chain as Chain
|
||||
import Internal.Tools.LoginValues exposing (AccessToken)
|
||||
import Internal.Api.CredUpdate as C exposing (CredUpdate)
|
||||
import Internal.Api.Versions.V1.Versions as V
|
||||
import Json.Encode as E
|
||||
import Internal.Tools.LoginValues exposing (AccessToken)
|
||||
import Internal.Tools.SpecEnums as Enums
|
||||
import Json.Encode as E
|
||||
|
||||
|
||||
type alias FutureTask =
|
||||
C.FutureTask
|
||||
|
||||
type alias FutureTask = C.FutureTask
|
||||
|
||||
type alias GetEventInput =
|
||||
{ accessToken : AccessToken
|
||||
|
@ -20,6 +24,7 @@ type alias GetEventInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
getEvent : GetEventInput -> FutureTask
|
||||
getEvent { accessToken, baseUrl, eventId, roomId, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
@ -28,6 +33,7 @@ getEvent { accessToken, baseUrl, eventId, roomId, versions } =
|
|||
|> Chain.andThen (C.getEvent { eventId = eventId, roomId = roomId })
|
||||
|> C.toTask
|
||||
|
||||
|
||||
type alias InviteInput =
|
||||
{ accessToken : AccessToken
|
||||
, baseUrl : String
|
||||
|
@ -37,6 +43,7 @@ type alias InviteInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
invite : InviteInput -> FutureTask
|
||||
invite { accessToken, baseUrl, reason, roomId, userId, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
@ -45,6 +52,7 @@ invite { accessToken, baseUrl, reason, roomId, userId, versions } =
|
|||
|> Chain.andThen (C.invite { reason = reason, roomId = roomId, userId = userId })
|
||||
|> C.toTask
|
||||
|
||||
|
||||
type alias JoinedMembersInput =
|
||||
{ accessToken : AccessToken
|
||||
, baseUrl : String
|
||||
|
@ -52,6 +60,7 @@ type alias JoinedMembersInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
joinedMembers : JoinedMembersInput -> FutureTask
|
||||
joinedMembers { accessToken, baseUrl, roomId, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
@ -60,6 +69,7 @@ joinedMembers { accessToken, baseUrl, roomId, versions } =
|
|||
|> Chain.andThen (C.joinedMembers { roomId = roomId })
|
||||
|> C.toTask
|
||||
|
||||
|
||||
type alias RedactInput =
|
||||
{ accessToken : AccessToken
|
||||
, baseUrl : String
|
||||
|
@ -70,6 +80,7 @@ type alias RedactInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
redact : RedactInput -> FutureTask
|
||||
redact { accessToken, baseUrl, eventId, extraTransactionNoise, reason, roomId, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
@ -94,6 +105,7 @@ redact { accessToken, baseUrl, eventId, extraTransactionNoise, reason, roomId, v
|
|||
(Chain.maybe <| C.getEvent { eventId = eventId, roomId = roomId })
|
||||
|> C.toTask
|
||||
|
||||
|
||||
type alias SendMessageEventInput =
|
||||
{ accessToken : AccessToken
|
||||
, baseUrl : String
|
||||
|
@ -104,6 +116,7 @@ type alias SendMessageEventInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
sendMessageEvent : SendMessageEventInput -> FutureTask
|
||||
sendMessageEvent { accessToken, baseUrl, content, eventType, extraTransactionNoise, roomId, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
@ -127,6 +140,7 @@ sendMessageEvent { accessToken, baseUrl, content, eventType, extraTransactionNoi
|
|||
-- TODO: Get event from API to see what it looks like
|
||||
|> C.toTask
|
||||
|
||||
|
||||
type alias SendStateKeyInput =
|
||||
{ accessToken : AccessToken
|
||||
, baseUrl : String
|
||||
|
@ -137,6 +151,7 @@ type alias SendStateKeyInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
sendStateKey : SendStateKeyInput -> FutureTask
|
||||
sendStateKey { accessToken, baseUrl, content, eventType, roomId, stateKey, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
@ -146,6 +161,7 @@ sendStateKey { accessToken, baseUrl, content, eventType, roomId, stateKey, versi
|
|||
-- TODO: Get event from API to see what it looks like
|
||||
|> C.toTask
|
||||
|
||||
|
||||
type alias SyncInput =
|
||||
{ accessToken : AccessToken
|
||||
, baseUrl : String
|
||||
|
@ -157,6 +173,7 @@ type alias SyncInput =
|
|||
, versions : Maybe V.Versions
|
||||
}
|
||||
|
||||
|
||||
sync : SyncInput -> FutureTask
|
||||
sync { accessToken, baseUrl, filter, fullState, setPresence, since, timeout, versions } =
|
||||
C.withBaseUrl baseUrl
|
||||
|
|
|
@ -5,6 +5,7 @@ import Internal.Api.Versions.V1.Versions as SO
|
|||
import Internal.Tools.Exceptions as X
|
||||
import Task exposing (Task)
|
||||
|
||||
|
||||
versionsV1 : { baseUrl : String } -> Task X.Error SO.Versions
|
||||
versionsV1 data =
|
||||
R.rawApiCall
|
||||
|
|
|
@ -8,14 +8,18 @@ Values like these usually imply that there is a leakage in the implementation or
|
|||
|
||||
-}
|
||||
|
||||
import Time
|
||||
import Hash
|
||||
import Time
|
||||
|
||||
|
||||
accessToken : String
|
||||
accessToken = "mistaken_access_token"
|
||||
accessToken =
|
||||
"mistaken_access_token"
|
||||
|
||||
|
||||
baseUrl : String
|
||||
baseUrl = "https://matrix.example.org"
|
||||
baseUrl =
|
||||
"https://matrix.example.org"
|
||||
|
||||
|
||||
eventId : String
|
||||
|
@ -52,10 +56,12 @@ sender : String
|
|||
sender =
|
||||
"@alice:example.org"
|
||||
|
||||
|
||||
transactionId : String
|
||||
transactionId =
|
||||
"elm" ++ (Hash.fromString "leaked_transactionId" |> Hash.toString)
|
||||
|
||||
|
||||
versions : List String
|
||||
versions =
|
||||
[]
|
||||
|
|
|
@ -5,8 +5,8 @@ module Internal.Room exposing (..)
|
|||
|
||||
import Dict
|
||||
import Internal.Api.CredUpdate exposing (CredUpdate)
|
||||
import Internal.Api.Task as Api
|
||||
import Internal.Api.Sync.V2.SpecObjects as Sync
|
||||
import Internal.Api.Task as Api
|
||||
import Internal.Context as Context exposing (Context)
|
||||
import Internal.Event as Event exposing (Event)
|
||||
import Internal.Tools.Exceptions as X
|
||||
|
|
|
@ -51,6 +51,7 @@ getEventById : String -> IRoom -> Maybe IEvent
|
|||
getEventById eventId (IRoom room) =
|
||||
Hashdict.get eventId room.events
|
||||
|
||||
|
||||
getStateEvent : { eventType : String, stateKey : String } -> IRoom -> Maybe IEvent
|
||||
getStateEvent data (IRoom room) =
|
||||
room.timeline
|
||||
|
|
Loading…
Reference in New Issue