diff --git a/ProjectLighthouse/Types/Serialization/Activity/Events/GameEvent.cs b/ProjectLighthouse/Types/Serialization/Activity/Events/GameEvent.cs index d69d626f..649907d5 100644 --- a/ProjectLighthouse/Types/Serialization/Activity/Events/GameEvent.cs +++ b/ProjectLighthouse/Types/Serialization/Activity/Events/GameEvent.cs @@ -184,6 +184,7 @@ public class GameEvent : ILbpSerializable, INeedsPreparationForSerialization }, EventType.UploadPhoto => new GamePhotoUploadEvent { + PhotoId = ((PhotoActivityEntity)activity.Activity).PhotoId, Slot = new ReviewSlot { SlotId = targetId, diff --git a/ProjectLighthouse/Types/Serialization/Activity/Events/GamePhotoUploadEvent.cs b/ProjectLighthouse/Types/Serialization/Activity/Events/GamePhotoUploadEvent.cs index c2da06ed..62b9a948 100644 --- a/ProjectLighthouse/Types/Serialization/Activity/Events/GamePhotoUploadEvent.cs +++ b/ProjectLighthouse/Types/Serialization/Activity/Events/GamePhotoUploadEvent.cs @@ -35,7 +35,6 @@ public class GamePhotoUploadEvent : GameEvent if (photo == null) return; this.PhotoParticipants = photo.PhotoSubjects.Select(ps => ps.User.Username).ToList(); - this.PhotoId = photo.PhotoId; if (photo.SlotId == null) return; diff --git a/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs b/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs index 3081f210..3f41b025 100644 --- a/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs +++ b/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs @@ -11,6 +11,7 @@ using LBPUnion.ProjectLighthouse.Types.Entities.Level; using LBPUnion.ProjectLighthouse.Types.Entities.Profile; using LBPUnion.ProjectLighthouse.Types.Entities.Token; using LBPUnion.ProjectLighthouse.Types.Entities.Website; +using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Serialization.News; using LBPUnion.ProjectLighthouse.Types.Serialization.Playlist; using LBPUnion.ProjectLighthouse.Types.Serialization.Slot; @@ -76,13 +77,13 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization public async Task PrepareSerialization(DatabaseContext database) { - this.Slots = await LoadEntities(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId)); + this.Slots = await LoadEntities(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId), s => s.Type == SlotType.User); this.Users = await LoadEntities(this.UserIds, user => GameUser.CreateFromEntity(user, this.TargetGame)); this.Playlists = await LoadEntities(this.PlaylistIds, GamePlaylist.CreateFromEntity); this.News = await LoadEntities(this.NewsIds, a => GameNewsObject.CreateFromEntity(a, this.TargetGame)); return; - async Task> LoadEntities(List ids, Func transformation) + async Task> LoadEntities(List ids, Func transformation, Func predicate = null) where TFrom : class { List results = new(); @@ -90,6 +91,9 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization foreach (int id in ids) { TFrom entity = await database.Set().FindAsync(id); + + if (predicate != null && !predicate(entity)) continue; + if (entity == null) continue; results.Add(transformation(entity));