Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on CheckForTraktTokenUpdate #1098

Merged
merged 1 commit into from
Jan 15, 2024
Merged

Work on CheckForTraktTokenUpdate #1098

merged 1 commit into from
Jan 15, 2024

Conversation

krbrs
Copy link
Contributor

@krbrs krbrs commented Jan 12, 2024

Have it read the expiration time from settings and not just refresh the token every 24h, only if it's going to expire in 45 days

Have it read the expiration time from settings and not just refresh the token every 24h, only if it's going to expire in 45 days
@krbrs krbrs marked this pull request as ready for review January 15, 2024 13:54
@krbrs
Copy link
Contributor Author

krbrs commented Jan 15, 2024

I could not test expiration and renewal yet. But at least I get a proper output of the token valid date in the logs while it's still valid and it does not try renewing it until a certain amount of time (45 days / 1/2 of the validity)

If someone can look into this code and optimize it if needed (or give feedback), that would be great

var expirationDate = DateTimeOffset.FromUnixTimeSeconds(long.Parse(settings.TraktTv.TokenExpirationDate)).DateTime;

// Check if force refresh is requested or the token is expired
if (forceRefresh || DateTime.Now.Add(TimeSpan.FromDays(45)) >= expirationDate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 45 days?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://discord.com/channels/96234011612958720/1148092356592160768/1195127627397214331

Initially I had it set to 30 days, but half would be 45 days so I set this. We can set it to whatever is fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Half of what

Copy link
Contributor Author

@krbrs krbrs Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Token lifetime - it's 90 days

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Looks good then

@da3dsoul da3dsoul merged commit 7b2e2f5 into ShokoAnime:master Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants