Fix news summary on LBP2

This commit is contained in:
Slendy 2023-09-05 23:34:44 -05:00
commit 7b6786ce87
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 9 additions and 7 deletions

View file

@ -76,6 +76,12 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization
public async Task PrepareSerialization(DatabaseContext database)
{
this.Slots = await LoadEntities<SlotEntity, SlotBase>(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId));
this.Users = await LoadEntities<UserEntity, GameUser>(this.UserIds, user => GameUser.CreateFromEntity(user, this.TargetGame));
this.Playlists = await LoadEntities<PlaylistEntity, GamePlaylist>(this.PlaylistIds, GamePlaylist.CreateFromEntity);
this.News = await LoadEntities<WebsiteAnnouncementEntity, GameNewsObject>(this.NewsIds, a => GameNewsObject.CreateFromEntity(a, this.TargetGame));
return;
async Task<List<TResult>> LoadEntities<TFrom, TResult>(List<int> ids, Func<TFrom, TResult> transformation)
where TFrom : class
{
@ -91,11 +97,6 @@ public class GameStream : ILbpSerializable, INeedsPreparationForSerialization
return results;
}
this.Slots = await LoadEntities<SlotEntity, SlotBase>(this.SlotIds, slot => SlotBase.CreateFromEntity(slot, this.TargetGame, this.TargetUserId));
this.Users = await LoadEntities<UserEntity, GameUser>(this.UserIds, user => GameUser.CreateFromEntity(user, this.TargetGame));
this.Playlists = await LoadEntities<PlaylistEntity, GamePlaylist>(this.PlaylistIds, GamePlaylist.CreateFromEntity);
this.News = await LoadEntities<WebsiteAnnouncementEntity, GameNewsObject>(this.NewsIds, GameNewsObject.CreateFromEntity);
}
public static GameStream CreateFromGroups

View file

@ -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(),