chore: add csharpier to husky, format backend with csharpier
This commit is contained in:
parent
5fab66444f
commit
7f971e8549
73 changed files with 2098 additions and 1048 deletions
|
@ -6,16 +6,21 @@ using Foxnouns.Backend.Services;
|
|||
|
||||
namespace Foxnouns.Backend.Jobs;
|
||||
|
||||
public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService objectStorageService, ILogger logger)
|
||||
: IInvocable, IInvocableWithPayload<AvatarUpdatePayload>
|
||||
public class UserAvatarUpdateInvocable(
|
||||
DatabaseContext db,
|
||||
ObjectStorageService objectStorageService,
|
||||
ILogger logger
|
||||
) : IInvocable, IInvocableWithPayload<AvatarUpdatePayload>
|
||||
{
|
||||
private readonly ILogger _logger = logger.ForContext<UserAvatarUpdateInvocable>();
|
||||
public required AvatarUpdatePayload Payload { get; set; }
|
||||
|
||||
public async Task Invoke()
|
||||
{
|
||||
if (Payload.NewAvatar != null) await UpdateUserAvatarAsync(Payload.Id, Payload.NewAvatar);
|
||||
else await ClearUserAvatarAsync(Payload.Id);
|
||||
if (Payload.NewAvatar != null)
|
||||
await UpdateUserAvatarAsync(Payload.Id, Payload.NewAvatar);
|
||||
else
|
||||
await ClearUserAvatarAsync(Payload.Id);
|
||||
}
|
||||
|
||||
private async Task UpdateUserAvatarAsync(Snowflake id, string newAvatar)
|
||||
|
@ -25,7 +30,10 @@ public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService
|
|||
var user = await db.Users.FindAsync(id);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.Warning("Update avatar job queued for {UserId} but no user with that ID exists", id);
|
||||
_logger.Warning(
|
||||
"Update avatar job queued for {UserId} but no user with that ID exists",
|
||||
id
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,7 +55,11 @@ public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService
|
|||
}
|
||||
catch (ArgumentException ae)
|
||||
{
|
||||
_logger.Warning("Invalid data URI for new avatar for user {UserId}: {Reason}", id, ae.Message);
|
||||
_logger.Warning(
|
||||
"Invalid data URI for new avatar for user {UserId}: {Reason}",
|
||||
id,
|
||||
ae.Message
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +70,10 @@ public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService
|
|||
var user = await db.Users.FindAsync(id);
|
||||
if (user == null)
|
||||
{
|
||||
_logger.Warning("Clear avatar job queued for {UserId} but no user with that ID exists", id);
|
||||
_logger.Warning(
|
||||
"Clear avatar job queued for {UserId} but no user with that ID exists",
|
||||
id
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,4 +90,4 @@ public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService
|
|||
}
|
||||
|
||||
public static string Path(Snowflake id, string hash) => $"users/{id}/avatars/{hash}.webp";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue