Fix invalid heartbeats from inactive STM accounts

It was possible before if the inventory state was the same as previously announced, even if server purged the info long time ago. Also, add required logic for recovery if that happens regardless.
This commit is contained in:
Archi
2024-01-03 00:23:27 +01:00
parent ab01733860
commit 3d503ed5ee
2 changed files with 57 additions and 6 deletions

View File

@@ -4,7 +4,7 @@
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
// |
// Copyright 2015-2023 Łukasz "JustArchi" Domeradzki
// Copyright 2015-2024 Łukasz "JustArchi" Domeradzki
// Contact: JustArchi@JustArchi.net
// |
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,12 +63,28 @@ internal sealed class BotCache : SerializableFile {
}
}
internal DateTime? LastRequestAt {
get => BackingLastRequestAt;
set {
if (BackingLastRequestAt == value) {
return;
}
BackingLastRequestAt = value;
Utilities.InBackground(Save);
}
}
[JsonProperty]
private string? BackingLastAnnouncedTradeToken;
[JsonProperty]
private string? BackingLastInventoryChecksumBeforeDeduplication;
[JsonProperty]
private DateTime? BackingLastRequestAt;
private BotCache(string filePath) : this() {
ArgumentException.ThrowIfNullOrEmpty(filePath);
@@ -84,6 +100,9 @@ internal sealed class BotCache : SerializableFile {
[UsedImplicitly]
public bool ShouldSerializeBackingLastInventoryChecksumBeforeDeduplication() => !string.IsNullOrEmpty(BackingLastInventoryChecksumBeforeDeduplication);
[UsedImplicitly]
public bool ShouldSerializeBackingLastRequestAt() => BackingLastRequestAt.HasValue;
[UsedImplicitly]
public bool ShouldSerializeLastAnnouncedAssetsForListing() => LastAnnouncedAssetsForListing.Count > 0;