47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Foxnouns.Backend.Database;
|
|
using Foxnouns.Backend.Database.Models;
|
|
using Foxnouns.Backend.Utils;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Foxnouns.Backend.Services;
|
|
|
|
public class SupportRendererService(UserRendererService userRenderer)
|
|
{
|
|
public ConversationResponse ToResponse(SupportConversation c) =>
|
|
new(
|
|
c.Id,
|
|
userRenderer.RenderPartialUser(c.User),
|
|
c.Title,
|
|
userRenderer.TryRenderPartialUser(c.AssignedTo),
|
|
c.Status
|
|
);
|
|
|
|
public MessageResponse ToResponse(SupportMessage m, bool modView = false) =>
|
|
new(
|
|
m.Id,
|
|
m.IsAnonymous
|
|
? modView
|
|
? userRenderer.RenderPartialUser(m.User)
|
|
: null
|
|
: userRenderer.RenderPartialUser(m.User),
|
|
m.IsAnonymous,
|
|
m.Content
|
|
);
|
|
|
|
public record ConversationResponse(
|
|
Snowflake Id,
|
|
UserRendererService.PartialUser User,
|
|
string Title,
|
|
UserRendererService.PartialUser? AssignedTo,
|
|
[property: JsonConverter(typeof(ScreamingSnakeCaseEnumConverter))]
|
|
SupportConversationStatus Status
|
|
);
|
|
|
|
public record MessageResponse(
|
|
Snowflake Id,
|
|
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
|
UserRendererService.PartialUser? User,
|
|
bool IsAnonymous,
|
|
string? Content
|
|
);
|
|
}
|