mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-03 01:09:29 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using Sandbox.Services.Players;
|
|
|
|
namespace Sandbox.Services;
|
|
|
|
/// <summary>
|
|
/// Activity Feed
|
|
/// </summary>
|
|
public sealed class Feed
|
|
{
|
|
public DateTimeOffset Timestamp { get; init; }
|
|
public string Text { get; init; }
|
|
public string Url { get; init; }
|
|
public string EntryType { get; init; }
|
|
public string Image { get; init; }
|
|
public Profile Player { get; init; }
|
|
public Package Package { get; init; }
|
|
|
|
// Internal - because exposed through MenuUtility because games don't need to access this
|
|
internal static async Task<Feed[]> GetFeed( int take = 20 )
|
|
{
|
|
take = take.Clamp( 1, 50 );
|
|
|
|
try
|
|
{
|
|
var posts = await Sandbox.Backend.Players.GetFeed( AccountInformation.SteamId, take );
|
|
if ( posts is null ) return Array.Empty<Feed>();
|
|
|
|
return posts.Select( x => From( x ) ).ToArray();
|
|
}
|
|
catch ( Exception )
|
|
{
|
|
return default;
|
|
}
|
|
}
|
|
internal static Feed From( PlayerFeedEntry p )
|
|
{
|
|
if ( p is null ) return default;
|
|
|
|
return new Feed
|
|
{
|
|
Timestamp = p.Timestamp,
|
|
Text = p.Text,
|
|
Url = p.Url,
|
|
EntryType = p.EntryType,
|
|
Image = p.Image,
|
|
Player = Sandbox.Services.Players.Profile.From( p.Player ),
|
|
Package = RemotePackage.FromDto( p.Package ),
|
|
};
|
|
}
|
|
}
|