File tree 2 files changed +28
-1
lines changed
matrix-client/src/Network/Matrix
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ module Network.Matrix.Client
23
23
LoginResponse (.. ),
24
24
getTokenFromEnv ,
25
25
createSession ,
26
+ createWithSession ,
27
+ createWithSessionIO ,
26
28
login ,
27
29
loginToken ,
28
30
logout ,
@@ -31,6 +33,7 @@ module Network.Matrix.Client
31
33
MatrixM ,
32
34
MatrixIO ,
33
35
runMatrixM ,
36
+ runMatrixIO ,
34
37
MatrixError (.. ),
35
38
retry ,
36
39
retryWithLog ,
@@ -180,6 +183,7 @@ import Network.Matrix.Internal
180
183
mkRequest' ,
181
184
retry ,
182
185
retryWithLog ,
186
+ runMatrixIO ,
183
187
runMatrixM ,
184
188
)
185
189
import Network.Matrix.Room
@@ -238,6 +242,29 @@ createSession ::
238
242
IO ClientSession
239
243
createSession baseUrl' token' = ClientSession baseUrl' token' <$> mkManager
240
244
245
+ createWithSession ::
246
+ MonadIO m =>
247
+ -- | The matrix client-server base url, e.g. "https://matrix.org"
248
+ T. Text ->
249
+ -- | The user token
250
+ MatrixToken ->
251
+ -- | The matrix action to perform
252
+ MatrixM m a ->
253
+ m (Either MatrixError a )
254
+ createWithSession baseUrl' token' action = do
255
+ session <- liftIO $ createSession baseUrl' token'
256
+ runMatrixM session action
257
+
258
+ createWithSessionIO ::
259
+ -- | The matrix client-server base url, e.g. "https://matrix.org"
260
+ T. Text ->
261
+ -- | The user token
262
+ MatrixToken ->
263
+ -- | The matrix action to perform
264
+ MatrixIO a ->
265
+ IO (Either MatrixError a )
266
+ createWithSessionIO = createWithSession
267
+
241
268
mkRequest :: MonadIO m => Bool -> T. Text -> MatrixM m HTTP. Request
242
269
mkRequest auth path = do
243
270
ClientSession {.. } <- ask
Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ runMatrixM session = flip runReaderT session . runExceptT . unMatrixM
194
194
-- | Run Matrix actions in 'IO'.
195
195
runMatrixIO :: ClientSession -> MatrixM IO a -> IO (Either MatrixError a )
196
196
runMatrixIO = runMatrixM
197
-
197
+
198
198
-- | Retry a network action
199
199
retryWithLog ::
200
200
(MonadMask m , MonadIO m ) =>
You can’t perform that action at this time.
0 commit comments