chore: add csharpier to husky, format backend with csharpier

This commit is contained in:
sam 2024-10-02 00:28:07 +02:00
parent 5fab66444f
commit 7f971e8549
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
73 changed files with 2098 additions and 1048 deletions

View file

@ -11,20 +11,30 @@ public class Application : BaseModel
public required string[] Scopes { get; init; }
public required string[] RedirectUris { get; init; }
public static Application Create(ISnowflakeGenerator snowflakeGenerator, string name, string[] scopes,
string[] redirectUrls)
public static Application Create(
ISnowflakeGenerator snowflakeGenerator,
string name,
string[] scopes,
string[] redirectUrls
)
{
var clientId = RandomNumberGenerator.GetHexString(32, true);
var clientSecret = AuthUtils.RandomToken();
if (scopes.Except(AuthUtils.ApplicationScopes).Any())
{
throw new ArgumentException("Invalid scopes passed to Application.Create", nameof(scopes));
throw new ArgumentException(
"Invalid scopes passed to Application.Create",
nameof(scopes)
);
}
if (redirectUrls.Any(s => !AuthUtils.ValidateRedirectUri(s)))
{
throw new ArgumentException("Invalid redirect URLs passed to Application.Create", nameof(redirectUrls));
throw new ArgumentException(
"Invalid redirect URLs passed to Application.Create",
nameof(redirectUrls)
);
}
return new Application
@ -34,7 +44,7 @@ public class Application : BaseModel
ClientSecret = clientSecret,
Name = name,
Scopes = scopes,
RedirectUris = redirectUrls
RedirectUris = redirectUrls,
};
}
}
}

View file

@ -20,4 +20,4 @@ public enum AuthType
Tumblr,
Fediverse,
Email,
}
}

View file

@ -11,5 +11,5 @@ public class FediverseApplication : BaseModel
public enum FediverseInstanceType
{
MastodonApi,
MisskeyApi
}
MisskeyApi,
}

View file

@ -15,4 +15,4 @@ public class FieldEntry
public class Pronoun : FieldEntry
{
public string? DisplayText { get; set; }
}
}

View file

@ -18,4 +18,4 @@ public class Member : BaseModel
public Snowflake UserId { get; init; }
public User User { get; init; } = null!;
}
}

View file

@ -22,4 +22,4 @@ public class MemberFlag
public required Snowflake MemberId { get; init; }
public required Snowflake PrideFlagId { get; init; }
public PrideFlag PrideFlag { get; init; } = null!;
}
}

View file

@ -8,4 +8,4 @@ public class TemporaryKey
public required string Key { get; init; }
public required string Value { get; set; }
public Instant Expires { get; init; }
}
}

View file

@ -14,4 +14,4 @@ public class Token : BaseModel
public Snowflake ApplicationId { get; set; }
public Application Application { get; set; } = null!;
}
}

View file

@ -37,7 +37,9 @@ public class User : BaseModel
public bool Deleted { get; set; }
public Instant? DeletedAt { get; set; }
public Snowflake? DeletedBy { get; set; }
[NotMapped] public bool? SelfDelete => Deleted ? DeletedBy != null : null;
[NotMapped]
public bool? SelfDelete => Deleted ? DeletedBy != null : null;
public class CustomPreference
{
@ -69,4 +71,4 @@ public enum PreferenceSize
public class UserSettings
{
public bool? DarkMode { get; set; } = null;
}
}