mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-09 23:37:54 +00:00
Use a proper user agent when fetching images
This commit is contained in:
parent
55c56c4e58
commit
41427db178
10 changed files with 106 additions and 87 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -22,12 +23,14 @@ namespace PluralKit.Bot
|
|||
private readonly IDatabase _db;
|
||||
private readonly ModelRepository _repo;
|
||||
private readonly EmbedService _embeds;
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public Groups(IDatabase db, ModelRepository repo, EmbedService embeds)
|
||||
public Groups(IDatabase db, ModelRepository repo, EmbedService embeds, HttpClient client)
|
||||
{
|
||||
_db = db;
|
||||
_repo = repo;
|
||||
_embeds = embeds;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task CreateGroup(Context ctx)
|
||||
|
|
@ -200,7 +203,7 @@ namespace PluralKit.Bot
|
|||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
|
||||
await AvatarUtils.VerifyAvatarOrThrow(img.Url);
|
||||
await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url);
|
||||
|
||||
await _db.Execute(c => _repo.UpdateGroup(c, target.Id, new GroupPatch {Icon = img.Url}));
|
||||
|
||||
|
|
@ -262,7 +265,7 @@ namespace PluralKit.Bot
|
|||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
|
||||
await AvatarUtils.VerifyAvatarOrThrow(img.Url, isFullSizeImage: true);
|
||||
await AvatarUtils.VerifyAvatarOrThrow(_client, img.Url, isFullSizeImage: true);
|
||||
|
||||
await _db.Execute(c => _repo.UpdateGroup(c, target.Id, new GroupPatch {BannerImage = img.Url}));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue