From f18dbcc941c1eeb2ac3a2de7427d0e6ce886f70e Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Tue, 4 Apr 2023 16:11:50 +0200 Subject: [PATCH] Force access token on account data + fix bug --- src/Internal/Api/SetAccountData/Api.elm | 6 ++++-- src/Internal/Vault.elm | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Internal/Api/SetAccountData/Api.elm b/src/Internal/Api/SetAccountData/Api.elm index 5225c65..783fb46 100644 --- a/src/Internal/Api/SetAccountData/Api.elm +++ b/src/Internal/Api/SetAccountData/Api.elm @@ -29,7 +29,8 @@ setAccountDataV1 { content, eventType, roomId } context = R.callApi "PUT" "/_matrix/client/r0/user/{userId}/account_data/{type}" ) >> R.withAttributes - [ R.replaceInUrl "type" eventType + [ R.accessToken + , R.replaceInUrl "type" eventType , R.replaceInUrl "userId" (Context.getUserId context) , R.fullBody content ] @@ -48,7 +49,8 @@ setAccountDataV2 { content, eventType, roomId } context = R.callApi "PUT" "/_matrix/client/v3/user/{userId}/account_data/{type}" ) >> R.withAttributes - [ R.replaceInUrl "type" eventType + [ R.accessToken + , R.replaceInUrl "type" eventType , R.replaceInUrl "userId" (Context.getUserId context) , R.fullBody content ] diff --git a/src/Internal/Vault.elm b/src/Internal/Vault.elm index 14afe1e..3ae756c 100644 --- a/src/Internal/Vault.elm +++ b/src/Internal/Vault.elm @@ -334,6 +334,9 @@ updateWith vaultUpdate ((Vault ({ cred, context } as data)) as vault) = LoggedInWithUsernameAndPassword _ output -> Vault { data | context = Credentials.addToken output.accessToken context } +getUsername : Vault -> Maybe String +getUsername (Vault { context }) = + Credentials.getUserId context {-| Set personal account data -}