Skip to content

inviteToRoom works but fails to parse JSON response and raises exception #32

@schoettl

Description

@schoettl

I use this client to create a room and then invite another user.

It works so far, it does create the room and invite the user. But then, I get an exception:

user error (Error in $: parsing () failed, expected Array, but encountered Object)

It seems to be a Aeson parse exception on the response returned by the matrix server. I could only handle that exception with a try/catch but it seems like a bug in this package to me.

I'm using version 0.1.4.3 (latest on hackage).


This is my code:

createPrivateMatrixRoom :: ClientSession -> Text -> Text -> Text -> [UserID] -> IO ()
createPrivateMatrixRoom sess alias name description users = do
  roomResult <- createRoom sess $ RoomCreateRequest PrivateChat alias name description
  case roomResult of
    Right roomId -> do
      inviteResults <- mapM (flip (inviteToRoom sess roomId) Nothing) users
      case lefts inviteResults of
        [] -> return ()
        err -> error $ "error: could not invite some users. details: " ++ show err
    Left err -> error $ "error: could not create matrix room, maybe due to existing canonical alias. details: " ++ show err

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions