chore: merge conflicts

This commit is contained in:
Sami Mazouz 2024-03-02 11:34:10 +01:00
parent 78ed7d5782
commit 6f942addb0
No known key found for this signature in database
4 changed files with 32 additions and 8 deletions

View File

@ -108,7 +108,7 @@
"php": "^8.1",
"ext-json": "*",
"components/font-awesome": "^5.15.0",
"composer/composer": "^2.0",
"composer/composer": "^2.7",
"dflydev/fig-cookies": "^3.0",
"doctrine/dbal": "^3.6.2",
"dragonmantank/cron-expression": "^3.3",

View File

@ -93,7 +93,7 @@ class TagResource extends AbstractDatabaseResource
Schema\Str::make('color')
->writable()
->nullable()
->regex('/^#([a-f0-9]{6}|[a-f0-9]{3})$/i'),
->rule('hex_color'),
Schema\Str::make('icon')
->writable()
->nullable(),

View File

@ -18,6 +18,7 @@ use Flarum\User\Event\Saving;
use Flarum\User\Exception\NotAuthenticatedException;
use Flarum\User\RegistrationToken;
use Flarum\User\User;
use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
@ -393,9 +394,30 @@ class UserResource extends AbstractDatabaseResource
]);
}
$image = $this->imageManager->make($url);
$urlContents = $this->retrieveAvatarFromUrl($url);
$this->avatarUploader->upload($user, $image);
if ($urlContents !== null) {
$image = $this->imageManager->read($urlContents);
$this->avatarUploader->upload($user, $image);
}
}
private function retrieveAvatarFromUrl(string $url): ?string
{
$client = new Client();
try {
$response = $client->get($url);
} catch (\Exception $e) {
return null;
}
if ($response->getStatusCode() !== 200) {
return null;
}
return $response->getBody()->getContents();
}
private function fulfillToken(User $user, RegistrationToken $token): void

View File

@ -306,11 +306,13 @@ class ModelTest extends TestCase
$this->app();
$group1 = new Group;
$group2 = new Group;
Group::boot();
$this->assertEquals(1, $group1->counter);
$this->assertEquals(2, $group2->counter);
$group1 = new Group();
$group2 = new Group();
$this->assertEquals(3, $group1->counter);
$this->assertEquals(4, $group2->counter);
}
/**