refactor(backend): move all request/response types to a new Dto namespace
This commit is contained in:
parent
f8e6032449
commit
8bd4449804
21 changed files with 310 additions and 316 deletions
47
Foxnouns.Backend/Dto/Auth.cs
Normal file
47
Foxnouns.Backend/Dto/Auth.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using NodaTime;
|
||||
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record CallbackResponse(
|
||||
bool HasAccount,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] string? Ticket,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] string? RemoteUsername,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] UserResponse? User,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] string? Token,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] Instant? ExpiresAt
|
||||
);
|
||||
|
||||
public record UrlsResponse(bool EmailEnabled, string? Discord, string? Google, string? Tumblr);
|
||||
|
||||
public record AuthResponse(UserResponse User, string Token, Instant ExpiresAt);
|
||||
|
||||
public record SingleUrlResponse(string Url);
|
||||
|
||||
public record AddOauthAccountResponse(
|
||||
Snowflake Id,
|
||||
[property: JsonConverter(typeof(ScreamingSnakeCaseEnumConverter))] AuthType Type,
|
||||
string RemoteId,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] string? RemoteUsername
|
||||
);
|
||||
|
||||
public record OauthRegisterRequest(string Ticket, string Username);
|
||||
|
||||
public record CallbackRequest(string Code, string State);
|
||||
|
||||
public record EmailLoginRequest(string Email, string Password);
|
||||
|
||||
public record EmailRegisterRequest(string Email);
|
||||
|
||||
public record EmailCompleteRegistrationRequest(string Ticket, string Username, string Password);
|
||||
|
||||
public record EmailCallbackRequest(string State);
|
||||
|
||||
public record EmailChangePasswordRequest(string Current, string New);
|
||||
|
||||
public record FediverseCallbackRequest(string Instance, string Code, string State);
|
6
Foxnouns.Backend/Dto/DataExport.cs
Normal file
6
Foxnouns.Backend/Dto/DataExport.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
using NodaTime;
|
||||
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record DataExportResponse(string? Url, Instant? ExpiresAt);
|
17
Foxnouns.Backend/Dto/Flag.cs
Normal file
17
Foxnouns.Backend/Dto/Flag.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Utils;
|
||||
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record PrideFlagResponse(Snowflake Id, string ImageUrl, string Name, string? Description);
|
||||
|
||||
public record CreateFlagRequest(string Name, string Image, string? Description);
|
||||
|
||||
public record CreateFlagResponse(Snowflake Id, string Name, string? Description);
|
||||
|
||||
public class UpdateFlagRequest : PatchRequest
|
||||
{
|
||||
public string? Name { get; init; }
|
||||
public string? Description { get; init; }
|
||||
}
|
8
Foxnouns.Backend/Dto/Internal.cs
Normal file
8
Foxnouns.Backend/Dto/Internal.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record RequestDataRequest(string? Token, string Method, string Path);
|
||||
|
||||
public record RequestDataResponse(Snowflake? UserId, string Template);
|
61
Foxnouns.Backend/Dto/Member.cs
Normal file
61
Foxnouns.Backend/Dto/Member.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record CreateMemberRequest(
|
||||
string Name,
|
||||
string? DisplayName,
|
||||
string? Bio,
|
||||
string? Avatar,
|
||||
bool? Unlisted,
|
||||
string[]? Links,
|
||||
List<FieldEntry>? Names,
|
||||
List<Pronoun>? Pronouns,
|
||||
List<Field>? Fields
|
||||
);
|
||||
|
||||
public class UpdateMemberRequest : PatchRequest
|
||||
{
|
||||
public string? Name { get; init; }
|
||||
public string? DisplayName { get; init; }
|
||||
public string? Bio { get; init; }
|
||||
public string? Avatar { get; init; }
|
||||
public string[]? Links { get; init; }
|
||||
public FieldEntry[]? Names { get; init; }
|
||||
public Pronoun[]? Pronouns { get; init; }
|
||||
public Field[]? Fields { get; init; }
|
||||
public Snowflake[]? Flags { get; init; }
|
||||
public bool? Unlisted { get; init; }
|
||||
}
|
||||
|
||||
public record PartialMember(
|
||||
Snowflake Id,
|
||||
string Sid,
|
||||
string Name,
|
||||
string DisplayName,
|
||||
string? Bio,
|
||||
string? AvatarUrl,
|
||||
IEnumerable<FieldEntry> Names,
|
||||
IEnumerable<Pronoun> Pronouns,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] bool? Unlisted
|
||||
);
|
||||
|
||||
public record MemberResponse(
|
||||
Snowflake Id,
|
||||
string Sid,
|
||||
string Name,
|
||||
string DisplayName,
|
||||
string? Bio,
|
||||
string? AvatarUrl,
|
||||
string[] Links,
|
||||
IEnumerable<FieldEntry> Names,
|
||||
IEnumerable<Pronoun> Pronouns,
|
||||
IEnumerable<Field> Fields,
|
||||
IEnumerable<PrideFlagResponse> Flags,
|
||||
PartialUser User,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] bool? Unlisted
|
||||
);
|
21
Foxnouns.Backend/Dto/Meta.cs
Normal file
21
Foxnouns.Backend/Dto/Meta.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record MetaResponse(
|
||||
string Repository,
|
||||
string Version,
|
||||
string Hash,
|
||||
int Members,
|
||||
UserInfoResponse Users,
|
||||
LimitsResponse Limits
|
||||
);
|
||||
|
||||
public record UserInfoResponse(int Total, int ActiveMonth, int ActiveWeek, int ActiveDay);
|
||||
|
||||
public record LimitsResponse(
|
||||
int MemberCount,
|
||||
int BioLength,
|
||||
int CustomPreferences,
|
||||
int MaxAuthMethods,
|
||||
int MaxFlags
|
||||
);
|
82
Foxnouns.Backend/Dto/User.cs
Normal file
82
Foxnouns.Backend/Dto/User.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using NodaTime;
|
||||
|
||||
namespace Foxnouns.Backend.Dto;
|
||||
|
||||
public record UserResponse(
|
||||
Snowflake Id,
|
||||
string Sid,
|
||||
string Username,
|
||||
string? DisplayName,
|
||||
string? Bio,
|
||||
string? MemberTitle,
|
||||
string? AvatarUrl,
|
||||
string[] Links,
|
||||
IEnumerable<FieldEntry> Names,
|
||||
IEnumerable<Pronoun> Pronouns,
|
||||
IEnumerable<Field> Fields,
|
||||
Dictionary<Snowflake, User.CustomPreference> CustomPreferences,
|
||||
IEnumerable<PrideFlagResponse> Flags,
|
||||
int? UtcOffset,
|
||||
[property: JsonConverter(typeof(ScreamingSnakeCaseEnumConverter))] UserRole Role,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
IEnumerable<PartialMember>? Members,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
IEnumerable<AuthMethodResponse>? AuthMethods,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] bool? MemberListHidden,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] Instant? LastActive,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] Instant? LastSidReroll,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] string? Timezone
|
||||
);
|
||||
|
||||
public record AuthMethodResponse(
|
||||
Snowflake Id,
|
||||
[property: JsonConverter(typeof(ScreamingSnakeCaseEnumConverter))] AuthType Type,
|
||||
string RemoteId,
|
||||
[property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] string? RemoteUsername
|
||||
);
|
||||
|
||||
public record PartialUser(
|
||||
Snowflake Id,
|
||||
string Sid,
|
||||
string Username,
|
||||
string? DisplayName,
|
||||
string? AvatarUrl,
|
||||
Dictionary<Snowflake, User.CustomPreference> CustomPreferences
|
||||
);
|
||||
|
||||
public class UpdateUserSettingsRequest : PatchRequest
|
||||
{
|
||||
public bool? DarkMode { get; init; }
|
||||
}
|
||||
|
||||
public class CustomPreferenceUpdateRequest
|
||||
{
|
||||
public Snowflake? Id { get; init; }
|
||||
public required string Icon { get; set; }
|
||||
public required string Tooltip { get; set; }
|
||||
public PreferenceSize Size { get; set; }
|
||||
public bool Muted { get; set; }
|
||||
public bool Favourite { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateUserRequest : PatchRequest
|
||||
{
|
||||
public string? Username { get; init; }
|
||||
public string? DisplayName { get; init; }
|
||||
public string? Bio { get; init; }
|
||||
public string? Avatar { get; init; }
|
||||
public string[]? Links { get; init; }
|
||||
public FieldEntry[]? Names { get; init; }
|
||||
public Pronoun[]? Pronouns { get; init; }
|
||||
public Field[]? Fields { get; init; }
|
||||
public Snowflake[]? Flags { get; init; }
|
||||
public string? MemberTitle { get; init; }
|
||||
public bool? MemberListHidden { get; init; }
|
||||
public string? Timezone { get; init; }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue