refactor: more consistent field names, also in STYLE.md

This commit is contained in:
sam 2024-09-09 14:50:00 +02:00
parent 344a0071e5
commit c77ee660ca
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
14 changed files with 86 additions and 71 deletions

View file

@ -6,7 +6,7 @@ using Foxnouns.Backend.Services;
namespace Foxnouns.Backend.Jobs;
public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService objectStorage, ILogger logger)
public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService objectStorageService, ILogger logger)
: IInvocable, IInvocableWithPayload<AvatarUpdatePayload>
{
private readonly ILogger _logger = logger.ForContext<UserAvatarUpdateInvocable>();
@ -36,13 +36,13 @@ public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService
image.Seek(0, SeekOrigin.Begin);
var prevHash = user.Avatar;
await objectStorage.PutObjectAsync(Path(id, hash), image, "image/webp");
await objectStorageService.PutObjectAsync(Path(id, hash), image, "image/webp");
user.Avatar = hash;
await db.SaveChangesAsync();
if (prevHash != null && prevHash != hash)
await objectStorage.RemoveObjectAsync(Path(id, prevHash));
await objectStorageService.RemoveObjectAsync(Path(id, prevHash));
_logger.Information("Updated avatar for user {UserId}", id);
}
@ -69,7 +69,7 @@ public class UserAvatarUpdateInvocable(DatabaseContext db, ObjectStorageService
return;
}
await objectStorage.RemoveObjectAsync(Path(user.Id, user.Avatar));
await objectStorageService.RemoveObjectAsync(Path(user.Id, user.Avatar));
user.Avatar = null;
await db.SaveChangesAsync();