Skip to content

Commit

Permalink
Stub LBP1 news endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Sep 3, 2023
1 parent 3b87e83 commit 86034ac
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 1 deletion.
50 changes: 49 additions & 1 deletion Refresh.GameServer/Endpoints/Game/ActivityEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using Bunkum.CustomHttpListener.Parsing;
using Bunkum.HttpServer;
using Bunkum.HttpServer.Endpoints;
using Bunkum.HttpServer.Time;
using Realms.Sync;
using Refresh.GameServer.Database;
using Refresh.GameServer.Time;
using Refresh.GameServer.Types.Activity;
using Refresh.GameServer.Types.News;
using Refresh.GameServer.Types.Roles;
using Refresh.GameServer.Types.UserData;

namespace Refresh.GameServer.Endpoints.Game;

public class ActivityEndpoints : EndpointGroup
{
[GameEndpoint("stream", ContentType.Xml)]
[NullStatusCode(BadRequest)]
[Authentication(false)]
[MinimumRole(GameUserRole.Restricted)]
public ActivityPage? GetRecentActivity(RequestContext context, GameDatabaseContext database)
{
Expand All @@ -28,4 +32,48 @@ public class ActivityEndpoints : EndpointGroup
ActivityPage page = new(database, timestamp: timestamp, endTimestamp: endTimestamp);
return page;
}

[GameEndpoint("news", ContentType.Xml)]
[Authentication(false)]
[MinimumRole(GameUserRole.Restricted)]
public GameNewsResponse GetNews(RequestContext context, IDateTimeProvider time)
{
return new GameNewsResponse
{
Subcategory = new GameNewsSubcategory
{
Title = "Subcategory title",
Id = 1,
Item = new GameNewsItem
{
Id = 2,
Subject = "Item subject",
Content = new GameNewsItemContent
{
Frame = new GameNewsFrame
{
Title = "Frame item title",
Width = 1024,
Item = new GameNewsFrameItem
{
Background = "Frame item background",
Content = "Frame item content",
Handle = new SerializedUserHandle
{
Username = "Username",
IconHash = "0",
},
Level = new GameNewsFrameItemSlot
{
Id = 0,
Type = "user",
},
Width = 1024,
},
},
},
},
},
};
}
}
10 changes: 10 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsFrame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace Refresh.GameServer.Types.News;

public class GameNewsFrame
{
[XmlAttribute("width")] public required long Width { get; set; }
[XmlElement("title")] public required string Title { get; set; }
[XmlElement("item")] public required GameNewsFrameItem Item { get; set; }
}
13 changes: 13 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsFrameItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;
using Refresh.GameServer.Types.UserData;

namespace Refresh.GameServer.Types.News;

public class GameNewsFrameItem
{
[XmlAttribute("width")] public required long Width { get; set; }
[XmlElement("slot")] public required GameNewsFrameItemSlot Level { get; set; }
[XmlElement("npHandle")] public required SerializedUserHandle Handle { get; set; }
[XmlElement("content")] public required string Content { get; set; }
[XmlElement("background")] public required string Background { get; set; }
}
12 changes: 12 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsFrameItemSlot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Xml.Serialization;

namespace Refresh.GameServer.Types.News;

public class GameNewsFrameItemSlot
{
[XmlElement("id")]
public required long Id { get; set; }

[XmlAttribute("type")]
public required string Type { get; set; }
}
10 changes: 10 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace Refresh.GameServer.Types.News;

public class GameNewsItem
{
[XmlElement("id")] public required long Id { get; set; }
[XmlElement("subject")] public required string Subject { get; set; }
[XmlElement("content")] public required GameNewsItemContent Content { get; set; }
}
8 changes: 8 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsItemContent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Xml.Serialization;

namespace Refresh.GameServer.Types.News;

public class GameNewsItemContent
{
[XmlElement("frame")] public required GameNewsFrame Frame { get; set; }
}
10 changes: 10 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace Refresh.GameServer.Types.News;

[XmlRoot("news")]
public class GameNewsResponse
{
[XmlElement("subcategory")]
public required GameNewsSubcategory Subcategory { get; set; }
}
10 changes: 10 additions & 0 deletions Refresh.GameServer/Types/News/GameNewsSubcategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace Refresh.GameServer.Types.News;

public class GameNewsSubcategory
{
[XmlElement("id")] public required long Id { get; set; }
[XmlElement("title")] public required string Title { get; set; }
[XmlElement("item")] public required GameNewsItem Item { get; set; }
}

0 comments on commit 86034ac

Please sign in to comment.