Skip to content

Commit

Permalink
Fix issue with unexpected prod data lol
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaFox161 committed Dec 31, 2024
1 parent 98e0164 commit 56d0738
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ data class CalendarMetadata(
) {
companion object {
suspend operator fun invoke(data: CalendarMetadataData): CalendarMetadata {
val aes = AESEncryption(data.privateKey)
val aes = if (data.privateKey.length == 16 && data.external) AESEncryption(data.privateKey) else null
val accessToken =
if (!data.expiresAt.asInstantMilli().isExpiredTtl() && data.external) aes.decrypt(data.accessToken)
if (aes != null && !data.expiresAt.asInstantMilli().isExpiredTtl()) aes.decrypt(data.accessToken)
.onErrorResume(IllegalBlockSizeException::class.java) {
Mono.empty()
}.awaitSingleOrNull()
else null // No point in trying to decrypt if it's expired
val refreshToken =
if (data.external) aes.decrypt(data.refreshToken)
.onErrorResume(IllegalBlockSizeException::class.java) {
Mono.empty()
}.awaitSingleOrNull()
else null // No point in trying to decrypt if calendar is not external, we don't use these internally
aes?.decrypt(data.refreshToken)?.onErrorResume(IllegalBlockSizeException::class.java) {
Mono.empty()
}?.awaitSingleOrNull() // No point in trying to decrypt if calendar is not external, we don't use these internally

return CalendarMetadata(
guildId = data.guildId.asSnowflake(),
Expand Down

0 comments on commit 56d0738

Please sign in to comment.