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 , coder = V1.coderSyncResponse
, contextChange = always identity , contextChange = always identity
, method = "GET" , method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ] , path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate = , 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 , coder = V2.coderSyncResponse
, contextChange = always identity , contextChange = always identity
, method = "GET" , method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ] , path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate = , 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 , coder = V3.coderSyncResponse
, contextChange = always identity , contextChange = always identity
, method = "GET" , method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ] , path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate = , 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 , coder = V4.coderSyncResponse
, contextChange = always identity , contextChange = always identity
, method = "GET" , method = "GET"
, path = [ "_matrix", "client", "v3", "sync" ] , path = [ "_matrix", "client", "r0", "sync" ]
, toUpdate = , 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 timeline.events
|> Maybe.map |> Maybe.map
(\events -> (\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 R.AddSync
{ events = newEvents { events = List.map (toEvent roomId) events
, filter = filter , filter = filter
, start = Just p , start =
, end = nextBatch case timeline.prevBatch of
} Just _ ->
timeline.prevBatch
else Nothing ->
R.More since
[ 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
, end = nextBatch , 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 : Filter, nextBatch : String, roomId : String, since : Maybe String } -> Timeline -> R.RoomUpdate
updateTimeline { filter, nextBatch, roomId, since } timeline = 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 R.AddSync
{ events = newEvents { events = List.map (toEvent roomId) timeline.events
, filter = filter , filter = filter
, start = Just p , start =
, end = nextBatch case timeline.prevBatch of
} Just _ ->
timeline.prevBatch
else Nothing ->
R.More since
[ 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
, end = nextBatch , 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 : Filter, nextBatch : String, roomId : String, since : Maybe String } -> Timeline -> R.RoomUpdate
updateTimeline { filter, nextBatch, roomId, since } timeline = 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 R.AddSync
{ events = newEvents { events = List.map (toEvent roomId) timeline.events
, filter = filter , filter = filter
, start = Just p , start =
, end = nextBatch case timeline.prevBatch of
} Just _ ->
timeline.prevBatch
else Nothing ->
R.More since
[ 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
, end = nextBatch , end = nextBatch
} }

View File

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

View File

@ -1,6 +1,6 @@
module Matrix exposing module Matrix exposing
( Vault, fromUserId, fromUsername ( Vault, fromUserId, fromUsername
, VaultUpdate, update, sync, logs , VaultUpdate, update, sync
, addAccessToken, sendMessageEvent , addAccessToken, sendMessageEvent
) )
@ -24,7 +24,7 @@ support a monolithic public registry. (:
## Keeping the Vault up-to-date ## Keeping the Vault up-to-date
@docs VaultUpdate, update, sync, logs @docs VaultUpdate, update, sync
## Debugging ## Debugging
@ -112,28 +112,6 @@ fromUsername { username, host, port_ } =
|> Vault |> 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. {-| Send a message event to a room.
This function can be used in a scenario where the user does not want to sync 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 exists and the user is able to send a message to, and instead just sends the
request to the Matrix API. 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 : sendMessageEvent :
{ content : E.Value { content : E.Value