Compare commits

..

No commits in common. "c473d601618da7c4f9539f6ebb625e0f6e0ebcd4" and "1aecb1116adb9bba0ecf89d36655a40e1d88e385" have entirely different histories.

6 changed files with 44 additions and 192 deletions

View File

@ -104,9 +104,9 @@ syncV1 data =
, coder = V1.coderSyncResponse
, contextChange = always identity
, method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ]
, path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate =
Debug.log "Handling output v1" >> V1.updateSyncResponse { filter = Filter.pass, since = data.since } >> Debug.log "Received"
V1.updateSyncResponse { filter = Filter.pass, since = data.since }
}
@ -126,9 +126,9 @@ syncV2 data =
, coder = V2.coderSyncResponse
, contextChange = always identity
, method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ]
, path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate =
Debug.log "Handling output v2" >> V2.updateSyncResponse { filter = Filter.pass, since = data.since } >> Debug.log "Received"
V2.updateSyncResponse { filter = Filter.pass, since = data.since }
}
@ -148,9 +148,9 @@ syncV3 data =
, coder = V3.coderSyncResponse
, contextChange = always identity
, method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ]
, path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate =
Debug.log "Handling output v3" >> V3.updateSyncResponse { filter = Filter.pass, since = data.since } >> Debug.log "Received"
V3.updateSyncResponse { filter = Filter.pass, since = data.since }
}
@ -170,7 +170,7 @@ syncV4 data =
, coder = V4.coderSyncResponse
, contextChange = always identity
, method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ]
, path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate =
Debug.log "Handling output v4" >> V4.updateSyncResponse { filter = Filter.pass, since = data.since } >> Debug.log "Received"
V4.updateSyncResponse { filter = Filter.pass, since = data.since }
}

View File

@ -935,54 +935,16 @@ updateTimeline { filter, nextBatch, roomId, since } timeline =
timeline.events
|> Maybe.map
(\events ->
let
limited : Bool
limited =
Maybe.withDefault False timeline.limited
newEvents : List Event.Event
newEvents =
List.map (toEvent roomId) events
in
case ( limited, timeline.prevBatch ) of
( False, Just p ) ->
if timeline.prevBatch == since then
R.AddSync
{ events = newEvents
{ events = List.map (toEvent roomId) events
, filter = filter
, start = Just p
, end = nextBatch
}
, start =
case timeline.prevBatch of
Just _ ->
timeline.prevBatch
else
R.More
[ R.AddSync
{ events = []
, filter = filter
, start = since
, end = p
}
, R.AddSync
{ events = newEvents
, filter = filter
, start = Just p
, end = nextBatch
}
]
( False, Nothing ) ->
R.AddSync
{ events = newEvents
, filter = filter
, start = since
, end = nextBatch
}
( True, _ ) ->
R.AddSync
{ events = newEvents
, filter = filter
, start = timeline.prevBatch
Nothing ->
since
, end = nextBatch
}
)

View File

@ -683,54 +683,16 @@ updateJoinedRoom data room =
updateTimeline : { filter : Filter, nextBatch : String, roomId : String, since : Maybe String } -> Timeline -> R.RoomUpdate
updateTimeline { filter, nextBatch, roomId, since } timeline =
let
limited : Bool
limited =
Maybe.withDefault False timeline.limited
newEvents : List Event.Event
newEvents =
List.map (toEvent roomId) timeline.events
in
case ( limited, timeline.prevBatch ) of
( False, Just p ) ->
if timeline.prevBatch == since then
R.AddSync
{ events = newEvents
{ events = List.map (toEvent roomId) timeline.events
, filter = filter
, start = Just p
, end = nextBatch
}
, start =
case timeline.prevBatch of
Just _ ->
timeline.prevBatch
else
R.More
[ R.AddSync
{ events = []
, filter = filter
, start = since
, end = p
}
, R.AddSync
{ events = newEvents
, filter = filter
, start = Just p
, end = nextBatch
}
]
( False, Nothing ) ->
R.AddSync
{ events = newEvents
, filter = filter
, start = since
, end = nextBatch
}
( True, _ ) ->
R.AddSync
{ events = newEvents
, filter = filter
, start = timeline.prevBatch
Nothing ->
since
, end = nextBatch
}

View File

@ -952,54 +952,16 @@ updateJoinedRoom data room =
updateTimeline : { filter : Filter, nextBatch : String, roomId : String, since : Maybe String } -> Timeline -> R.RoomUpdate
updateTimeline { filter, nextBatch, roomId, since } timeline =
let
limited : Bool
limited =
Maybe.withDefault False timeline.limited
newEvents : List Event.Event
newEvents =
List.map (toEvent roomId) timeline.events
in
case ( limited, timeline.prevBatch ) of
( False, Just p ) ->
if timeline.prevBatch == since then
R.AddSync
{ events = newEvents
{ events = List.map (toEvent roomId) timeline.events
, filter = filter
, start = Just p
, end = nextBatch
}
, start =
case timeline.prevBatch of
Just _ ->
timeline.prevBatch
else
R.More
[ R.AddSync
{ events = []
, filter = filter
, start = since
, end = p
}
, R.AddSync
{ events = newEvents
, filter = filter
, start = Just p
, end = nextBatch
}
]
( False, Nothing ) ->
R.AddSync
{ events = newEvents
, filter = filter
, start = since
, end = nextBatch
}
( True, _ ) ->
R.AddSync
{ events = newEvents
, filter = filter
, start = timeline.prevBatch
Nothing ->
since
, end = nextBatch
}

View File

@ -36,7 +36,7 @@ coder =
}
)
(Json.field.required
{ fieldName = "type"
{ fieldName = "eventType"
, toField = .eventType
, description =
[ "Event type, generally namespaced using the Java package naming convention."

View File

@ -1,6 +1,6 @@
module Matrix exposing
( Vault, fromUserId, fromUsername
, VaultUpdate, update, sync, logs
, VaultUpdate, update, sync
, addAccessToken, sendMessageEvent
)
@ -24,7 +24,7 @@ support a monolithic public registry. (:
## Keeping the Vault up-to-date
@docs VaultUpdate, update, sync, logs
@docs VaultUpdate, update, sync
## Debugging
@ -112,28 +112,6 @@ fromUsername { username, host, port_ } =
|> Vault
{-| The VaultUpdate is a complex type that helps update the Vault. However,
it also contains a human output!
Using this function, you can get a human output that describes everything that
the VaultUpdate has to tell the Vault.
The `channel` field describes the context of the log, allowing you to filter
further. For example:
- `debug` is a comprehensive channel describing everything the Elm runtime has
executed.
- `warn` contains warnings that aren't breaking, but relevant.
- `securityWarn` warns about potential security issues or potential attacks.
- `error` has errors that were encountered.
- `caughtError` has errors that were dealt with successfully.
-}
logs : VaultUpdate -> List { channel : String, content : String }
logs (VaultUpdate vu) =
vu.logs
{-| Send a message event to a room.
This function can be used in a scenario where the user does not want to sync
@ -141,18 +119,6 @@ the client, or is unable to. This function doesn't check whether the given room
exists and the user is able to send a message to, and instead just sends the
request to the Matrix API.
The fields stand for the following:
- `content` is the JSON object that is sent to the Matrix room.
- `eventType` is the event type that is sent to the Matrix room.
- `roomId` is the Matrix room ID.
- `toMsg` is the `msg` type that is returned after the message has been sent.
- `transactionId` is a unique identifier that helps the Matrix server
distringuish messages. If you send the same message with the same transactionId,
the server promises to register it only once.
- `vault` is the Matrix Vault that contains all the latest and most relevant
information.
-}
sendMessageEvent :
{ content : E.Value