Skip to content

Commit

Permalink
fix: fix vcard import to generate avatars (#5193)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored May 16, 2021
1 parent 16cd47e commit 6323a5d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion app/Services/VCard/ImportVCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use App\Services\BaseService;
use function Safe\preg_split;
use App\Models\Contact\Gender;
use App\Models\Contact\Address;
use App\Models\Contact\Contact;
use Illuminate\Validation\Rule;
use App\Helpers\CountriesHelper;
Expand All @@ -26,7 +25,9 @@
use App\Services\Contact\Tag\DetachTag;
use App\Models\Contact\ContactFieldType;
use App\Services\Contact\Tag\AssociateTag;
use App\Jobs\Avatars\GenerateDefaultAvatar;
use App\Services\Account\Photo\UploadPhoto;
use App\Jobs\Avatars\GetAvatarsFromInternet;
use App\Services\Contact\Avatar\UpdateAvatar;
use App\Services\Contact\Address\CreateAddress;
use App\Services\Contact\Address\UpdateAddress;
Expand Down Expand Up @@ -516,6 +517,8 @@ private function importEntry($contact, VCard $entry): Contact

$contact->save();

$this->addAvatars($contact);

return $contact;
}

Expand Down Expand Up @@ -1060,4 +1063,25 @@ private function importCategories(Contact $contact, VCard $entry)
]);
}
}

/**
* Add the different default avatars.
*
* @param Contact $contact
* @return void
*/
private function addAvatars(Contact $contact)
{
// set the default avatar color
if (! $contact->default_avatar_color) {
$contact->setAvatarColor();
$contact->save();
}

// populate the avatar from Adorable and grab the Gravatar
GetAvatarsFromInternet::dispatch($contact);

// also generate the default avatar
GenerateDefaultAvatar::dispatch($contact);
}
}

0 comments on commit 6323a5d

Please sign in to comment.