feat: add support for external avatar hosting service (#614)

This commit is contained in:
Astrid 2024-02-11 03:53:46 +01:00 committed by GitHub
parent 8befb1c857
commit 8157c6932e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 94 additions and 5 deletions

View file

@ -9,10 +9,12 @@ namespace PluralKit.Bot;
public class MemberAvatar
{
private readonly HttpClient _client;
private readonly AvatarHostingService _avatarHosting;
public MemberAvatar(HttpClient client)
public MemberAvatar(HttpClient client, AvatarHostingService avatarHosting)
{
_client = client;
_avatarHosting = avatarHosting;
}
private async Task AvatarClear(MemberAvatarLocation location, Context ctx, PKMember target, MemberGuildSettings? mgs)
@ -138,6 +140,8 @@ public class MemberAvatar
}
ctx.CheckSystem().CheckOwnMember(target);
avatarArg = await _avatarHosting.TryRehostImage(avatarArg.Value, AvatarHostingService.RehostedImageType.Avatar, ctx.Author.Id);
await AvatarUtils.VerifyAvatarOrThrow(_client, avatarArg.Value.Url);
await UpdateAvatar(location, ctx, target, avatarArg.Value.CleanUrl ?? avatarArg.Value.Url);
await PrintResponse(location, ctx, target, avatarArg.Value, guildData);