[skip ci] profile service job fixes
This commit is contained in:
1 parent
673d6b3602
commit
115b457241
7 files changed
+39
-21
No files matched your search
+2
-1
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fix Invidious tests - `Me at the zoo` video was getting blocked
|
- Invidious tests - `Me at the zoo` video was getting blocked
|
||||||
|
- Bug where logging out from inactive profile is not properly persisted
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,8 @@
|
|||||||
preferences="bind:../Preferences" />
|
preferences="bind:../Preferences" />
|
||||||
|
|
||||||
<ProfilesService id="ProfilesService"
|
<ProfilesService id="ProfilesService"
|
||||||
invidious="bind:../Invidious" />
|
invidious="bind:../Invidious"
|
||||||
|
jobQueue="bind:/JobQueue" />
|
||||||
|
|
||||||
<Innertube id="Innertube"
|
<Innertube id="Innertube"
|
||||||
jobQueue="bind:/JobQueue" />
|
jobQueue="bind:/JobQueue" />
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ function InitializeBindings()
|
|||||||
"preferences": "../Preferences"
|
"preferences": "../Preferences"
|
||||||
},
|
},
|
||||||
"ProfilesService": {
|
"ProfilesService": {
|
||||||
"invidious": "../Invidious"
|
"invidious": "../Invidious",
|
||||||
|
"jobQueue": "/JobQueue"
|
||||||
},
|
},
|
||||||
"Innertube": {
|
"Innertube": {
|
||||||
"jobQueue": "/JobQueue"
|
"jobQueue": "/JobQueue"
|
||||||
|
|||||||
+13
-4
@@ -1,7 +1,9 @@
|
|||||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||||
|
|
||||||
@asynctask
|
@job("ProfilesInvidiousUnregisterTokenJob")
|
||||||
function ProfilesInvidiousUnregisterTokenTask(input as object) as object
|
function ExecuteJob() as void
|
||||||
|
input = JobGetInput()
|
||||||
|
|
||||||
profileContentNodes = input.profileNodes
|
profileContentNodes = input.profileNodes
|
||||||
invidiousNode = input.invidious
|
invidiousNode = input.invidious
|
||||||
|
|
||||||
@@ -16,7 +18,14 @@ function ProfilesInvidiousUnregisterTokenTask(input as object) as object
|
|||||||
if not response.IsSuccess()
|
if not response.IsSuccess()
|
||||||
LogWarn(`Failed to unregister token: ${response.ErrorMessage()}`)
|
LogWarn(`Failed to unregister token: ${response.ErrorMessage()}`)
|
||||||
end if
|
end if
|
||||||
end for
|
|
||||||
|
|
||||||
return invalid
|
refreshToken = profileNode.refreshToken
|
||||||
|
if not StringUtils.IsNullOrEmpty(refreshToken)
|
||||||
|
authToken.token = refreshToken
|
||||||
|
response = service.UnregisterToken(authToken)
|
||||||
|
if not response.IsSuccess()
|
||||||
|
LogWarn(`Failed to unregister refresh token: ${response.ErrorMessage()}`)
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end for
|
||||||
end function
|
end function
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
import "pkg:/components/JobSystem/Jobs.bs"
|
||||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
import "pkg:/components/JobSystem/JobSystem.bs"
|
||||||
import "pkg:/source/utils/ArrayUtils.bs"
|
import "pkg:/source/utils/ArrayUtils.bs"
|
||||||
import "pkg:/source/utils/ColorUtils.bs"
|
import "pkg:/source/utils/ColorUtils.bs"
|
||||||
import "pkg:/source/utils/CryptoUtils.bs"
|
import "pkg:/source/utils/CryptoUtils.bs"
|
||||||
@@ -83,11 +83,12 @@ function LoadProfilesFromRegistry()
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if profileNodes.Count() > 0
|
if profileNodes.Count() > 0
|
||||||
AsyncTask.Start(Tasks.ProfilesVerifyTokensTask, {
|
input = {
|
||||||
profilesService: m.top
|
profilesService: m.top
|
||||||
invidious: m.invidious
|
invidious: m.invidious
|
||||||
profileNodes: profileNodes
|
profileNodes: profileNodes
|
||||||
})
|
}
|
||||||
|
JobSystem.QueueJob(m.jobQueue, Jobs.ProfilesVerifyTokensJob, input)
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -245,14 +246,16 @@ function LogoutWithProfile(profile as object) as void
|
|||||||
SetCurrentProfile(invalid)
|
SetCurrentProfile(invalid)
|
||||||
else
|
else
|
||||||
RefreshActiveProfileState(currentProfile)
|
RefreshActiveProfileState(currentProfile)
|
||||||
|
SaveUserProfilesToRegistry(invalid)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
m.top.onProfileLogout = true
|
m.top.onProfileLogout = true
|
||||||
|
|
||||||
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
|
input = {
|
||||||
invidious: m.invidious
|
invidious: m.invidious
|
||||||
profileNodes: [profile]
|
profileNodes: [profile]
|
||||||
})
|
}
|
||||||
|
JobSystem.QueueJob(m.jobQueue, Jobs.ProfilesInvidiousUnregisterTokenJob, input)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function LogoutWithProfiles(profiles as object) as void
|
function LogoutWithProfiles(profiles as object) as void
|
||||||
@@ -280,17 +283,18 @@ function LogoutWithProfiles(profiles as object) as void
|
|||||||
SetCurrentProfile(invalid)
|
SetCurrentProfile(invalid)
|
||||||
else
|
else
|
||||||
RefreshActiveProfileState(currentProfile)
|
RefreshActiveProfileState(currentProfile)
|
||||||
|
SaveUserProfilesToRegistry(invalid)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if onProfileLogout
|
if onProfileLogout
|
||||||
m.top.onProfileLogout = true
|
m.top.onProfileLogout = true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
AsyncTask.Start(Tasks.ProfilesInvidiousUnregisterTokenTask, {
|
input = {
|
||||||
profiles: m.top
|
|
||||||
invidious: m.invidious
|
invidious: m.invidious
|
||||||
profileNodes: profiles
|
profileNodes: profiles
|
||||||
})
|
}
|
||||||
|
JobSystem.QueueJob(m.jobQueue, Jobs.ProfilesInvidiousUnregisterTokenJob, input)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function LogoutWithAccessToken(accessToken as dynamic) as void
|
function LogoutWithAccessToken(accessToken as dynamic) as void
|
||||||
@@ -312,6 +316,7 @@ function LogoutWithAccessToken(accessToken as dynamic) as void
|
|||||||
SetCurrentProfile(invalid)
|
SetCurrentProfile(invalid)
|
||||||
else
|
else
|
||||||
RefreshActiveProfileState(currentProfile)
|
RefreshActiveProfileState(currentProfile)
|
||||||
|
SaveUserProfilesToRegistry(invalid)
|
||||||
end if
|
end if
|
||||||
m.top.onProfileLogout = true
|
m.top.onProfileLogout = true
|
||||||
exit for
|
exit for
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<field id="content" type="node" />
|
<field id="content" type="node" />
|
||||||
|
|
||||||
<field id="invidious" type="node" />
|
<field id="invidious" type="node" />
|
||||||
|
<field id="jobQueue" type="node" />
|
||||||
|
|
||||||
<function name="GetProfilesDto" />
|
<function name="GetProfilesDto" />
|
||||||
<function name="LoginWithProfile" />
|
<function name="LoginWithProfile" />
|
||||||
|
|||||||
+5
-5
@@ -1,8 +1,10 @@
|
|||||||
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
||||||
import "pkg:/source/utils/StringUtils.bs"
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
|
|
||||||
@asynctask
|
@job("ProfilesVerifyTokensJob")
|
||||||
function ProfilesVerifyTokensTask(input as object) as object
|
function ExecuteJob() as void
|
||||||
|
input = JobGetInput()
|
||||||
|
|
||||||
profilesNode = input.profilesService
|
profilesNode = input.profilesService
|
||||||
invidiousNode = input.invidious
|
invidiousNode = input.invidious
|
||||||
profileContentNodes = input.profileNodes
|
profileContentNodes = input.profileNodes
|
||||||
@@ -20,7 +22,7 @@ function ProfilesVerifyTokensTask(input as object) as object
|
|||||||
end for
|
end for
|
||||||
|
|
||||||
if invalidProfiles.Count() = 0
|
if invalidProfiles.Count() = 0
|
||||||
return invalid
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
profilesNode@.LogoutWithProfiles(invalidProfiles)
|
profilesNode@.LogoutWithProfiles(invalidProfiles)
|
||||||
@@ -36,6 +38,4 @@ function ProfilesVerifyTokensTask(input as object) as object
|
|||||||
message: message
|
message: message
|
||||||
title: Tr(Locale.Dialogs.UserLoggedOut)
|
title: Tr(Locale.Dialogs.UserLoggedOut)
|
||||||
})
|
})
|
||||||
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
Reference in new issue
Block a user