From 7b6786ce877708a5bfe53e37b8cf0f285b695fda Mon Sep 17 00:00:00 2001 From: Slendy Date: Tue, 5 Sep 2023 23:34:44 -0500 Subject: [PATCH] Fix news summary on LBP2 --- .../Types/Serialization/Activity/GameStream.cs | 11 ++++++----- .../Types/Serialization/News/GameNewsObject.cs | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs b/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs index 158f166e..3081f210 100644 --- a/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs +++ b/ProjectLighthouse/Types/Serialization/Activity/GameStream.cs @@ -76,6 +76,12 @@ 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.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) where TFrom : class { @@ -91,11 +97,6 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization return results; } - - this.Slots = await LoadEntities(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId)); - 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, GameNewsObject.CreateFromEntity); } public static GameStream CreateFromGroups diff --git a/ProjectLighthouse/Types/Serialization/News/GameNewsObject.cs b/ProjectLighthouse/Types/Serialization/News/GameNewsObject.cs index cc4b4659..ec1eeee0 100644 --- a/ProjectLighthouse/Types/Serialization/News/GameNewsObject.cs +++ b/ProjectLighthouse/Types/Serialization/News/GameNewsObject.cs @@ -2,6 +2,7 @@ using System.Xml.Serialization; using LBPUnion.ProjectLighthouse.Extensions; using LBPUnion.ProjectLighthouse.Types.Entities.Website; +using LBPUnion.ProjectLighthouse.Types.Users; namespace LBPUnion.ProjectLighthouse.Types.Serialization.News; @@ -33,12 +34,12 @@ public class GameNewsObject : ILbpSerializable [XmlElement("category")] public string Category { get; set; } - public static GameNewsObject CreateFromEntity(WebsiteAnnouncementEntity entity) => + public static GameNewsObject CreateFromEntity(WebsiteAnnouncementEntity entity, GameVersion gameVersion) => new() { Id = entity.AnnouncementId, Title = entity.Title, - Summary = "", + Summary = gameVersion == GameVersion.LittleBigPlanet2 ? entity.Content : "", Text = entity.Content, Category = "no_category", Timestamp = entity.PublishedAt.ToUnixTimeMilliseconds(),