Files
playlet-piped/playlet-lib/src/components/Services/ProfilesService/ProfilesVerifyTokensJob.bs
T

42 lines
1.2 KiB
Plaintext

import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/StringUtils.bs"
@job("ProfilesVerifyTokensJob")
function ExecuteJob() as void
input = JobGetInput()
profilesNode = input.profilesService
invidiousNode = input.invidious
profileContentNodes = input.profileNodes
service = new Invidious.InvidiousService(invidiousNode)
invalidProfiles = []
for each profileNode in profileContentNodes
if not StringUtils.IsNullOrEmpty(profileNode.refreshToken)
continue for
end if
if not service.VerifyTokenScope(profileNode.accessToken)
invalidProfiles.push(profileNode)
end if
end for
if invalidProfiles.Count() = 0
return
end if
profilesNode@.LogoutWithProfiles(invalidProfiles)
profileNames = []
for each profileNode in invalidProfiles
profileNames.push(profileNode.username)
end for
profileNames = profileNames.join(", ")
message = Tr(Locale.Dialogs.UserLoggedOutMessage).Replace("\n", `\n`).Replace("%1", profileNames)
DialogUtils.ShowDialogEx({
message: message
title: Tr(Locale.Dialogs.UserLoggedOut)
})
end function