Fix repeated weapon story unlock notifications by sending only changed stories in diffs

This commit is contained in:
Ilya Groshev
2026-04-16 14:36:05 +03:00
parent a61ae6b93e
commit 0ab2589277
17 changed files with 260 additions and 150 deletions
@@ -258,6 +258,27 @@ func sortedWeaponStoryRecords(user store.UserState) []map[string]any {
return records
}
func WeaponStoryRecordsForIds(user store.UserState, weaponIds []int32) string {
if len(weaponIds) == 0 {
return "[]"
}
records := make([]map[string]any, 0, len(weaponIds))
for _, weaponId := range weaponIds {
row, ok := user.WeaponStories[weaponId]
if !ok {
continue
}
records = append(records, map[string]any{
"userId": user.UserId,
"weaponId": row.WeaponId,
"releasedMaxStoryIndex": row.ReleasedMaxStoryIndex,
"latestVersion": row.LatestVersion,
})
}
s, _ := encodeJSONMaps(records...)
return s
}
func sortedWeaponNoteRecords(user store.UserState) []map[string]any {
weaponIds := make([]int32, 0, len(user.WeaponNotes))
for id := range user.WeaponNotes {