mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-11 00:07:55 +00:00
feat: add support for external avatar hosting service (#614)
This commit is contained in:
parent
8befb1c857
commit
8157c6932e
9 changed files with 94 additions and 5 deletions
|
|
@ -16,13 +16,15 @@ public class Member
|
|||
private readonly HttpClient _client;
|
||||
private readonly DispatchService _dispatch;
|
||||
private readonly EmbedService _embeds;
|
||||
private readonly AvatarHostingService _avatarHosting;
|
||||
|
||||
public Member(EmbedService embeds, HttpClient client,
|
||||
DispatchService dispatch)
|
||||
DispatchService dispatch, AvatarHostingService avatarHosting)
|
||||
{
|
||||
_embeds = embeds;
|
||||
_client = client;
|
||||
_dispatch = dispatch;
|
||||
_avatarHosting = avatarHosting;
|
||||
}
|
||||
|
||||
public async Task NewMember(Context ctx)
|
||||
|
|
@ -78,6 +80,8 @@ public class Member
|
|||
uriBuilder.Query = "";
|
||||
img.CleanUrl = uriBuilder.Uri.AbsoluteUri;
|
||||
|
||||
img = await _avatarHosting.TryRehostImage(img, AvatarHostingService.RehostedImageType.Avatar, ctx.Author.Id);
|
||||
|
||||
await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url);
|
||||
await ctx.Repository.UpdateMember(member.Id, new MemberPatch { AvatarUrl = img.CleanUrl ?? img.Url }, conn);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue