Skip to content

Commit 722034f

Browse files
schoettlTristanCacqueray
authored andcommitted
1 parent 3b641c5 commit 722034f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

matrix-client/src/Network/Matrix/Client.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,10 @@ inviteToRoom :: ClientSession -> RoomID -> UserID -> Maybe T.Text -> MatrixIO ()
631631
inviteToRoom session (RoomID rid) (UserID uid) reason = do
632632
request <- mkRequest session True $ "/_matrix/client/v3/rooms/" <> rid <> "/invite"
633633
let body = object $ [("user_id", toJSON uid)] <> catMaybes [fmap (("reason",) . toJSON) reason]
634-
doRequest session $
634+
fmap (ensureEmptyObject "invite") <$> (doRequest session $
635635
request { HTTP.method = "POST"
636636
, HTTP.requestBody = HTTP.RequestBodyLBS $ encode body
637-
}
637+
})
638638

639639
-- | Note that this API takes either a room ID or alias, unlike 'joinRoomById'
640640
-- https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3joinroomidoralias
@@ -1352,3 +1352,8 @@ tshow = T.pack . show
13521352

13531353
escapeUriComponent :: T.Text -> T.Text
13541354
escapeUriComponent = T.pack . URI.escapeURIString URI.isUnreserved . T.unpack
1355+
1356+
ensureEmptyObject :: String -> Value -> ()
1357+
ensureEmptyObject apiName value = case value of
1358+
Object xs | xs == mempty -> ()
1359+
_ -> error $ "Unknown " <> apiName <> " response: " <> show value

0 commit comments

Comments
 (0)