diff --git a/app/libs/Auth/Factories/UserFactory.php b/app/libs/Auth/Factories/UserFactory.php index cb4c0c0e..3148e606 100644 --- a/app/libs/Auth/Factories/UserFactory.php +++ b/app/libs/Auth/Factories/UserFactory.php @@ -14,6 +14,8 @@ use Auth\Group; use Auth\User; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; + /** * Class UserFactory * @package App\libs\Auth\Factories @@ -157,7 +159,7 @@ final class UserFactory if(isset($payload['public_profile_show_email'])) $user->setPublicProfileShowEmail(boolval($payload['public_profile_show_email'])); - if(isset($payload['email_verified']) && $payload['email_verified'] == true && !$user->isEmailVerified()) + if(isset($payload['email_verified']) && boolval($payload['email_verified']) === true && !$user->isEmailVerified()) $user->verifyEmail(); return $user; diff --git a/app/libs/Auth/Models/User.php b/app/libs/Auth/Models/User.php index 94eb441c..78ae57ef 100644 --- a/app/libs/Auth/Models/User.php +++ b/app/libs/Auth/Models/User.php @@ -813,8 +813,14 @@ class User extends BaseEntity */ public function getPic(): string { - if(!empty($this->pic)){ - return Storage::disk('swift')->url(sprintf("%s/%s", self::getProfilePicFolder(), $this->pic)); + try { + if (!empty($this->pic)) { + return Storage::disk('swift')->url(sprintf("%s/%s", self::getProfilePicFolder(), $this->pic)); + } + return $this->getGravatarUrl(); + } + catch (\Exception $ex) { + Log::warning($ex); } return $this->getGravatarUrl(); } @@ -1476,6 +1482,7 @@ SQL; public function verifyEmail() { if (!$this->email_verified) { + Log::debug(sprintf("User::verifyEmail verifying email %s", $this->email)); $this->email_verified = true; $this->spam_type = self::SpamTypeHam; $this->active = true; @@ -1564,15 +1571,16 @@ SQL; */ public function preUpdate(PreUpdateEventArgs $args) { - if($this->spam_type != self::SpamTypeNone && - !$args->hasChangedField("active") && - ($args->hasChangedField("bio") || $args->hasChangedField("email"))) { - // enqueue user for spam re checker - $this->resetSpamTypeClassification(); - Event::fire(new UserSpamStateUpdated($this->getId())); - } - if($args->hasChangedField("email")) { - // record email change + if($this->spam_type != self::SpamTypeNone ){ + if($args->hasChangedField("active")) return; + $bio_changed = $args->hasChangedField("bio") && !empty($args->getNewValue('bio')); + $email_changed = $args->hasChangedField("email"); + if( $bio_changed|| $email_changed) { + // enqueue user for spam re checker + Log::warning(sprintf("User::preUpdate user %s was marked for spam type reclasification.", $this->email)); + $this->resetSpamTypeClassification(); + Event::fire(new UserSpamStateUpdated($this->getId())); + } } }