Skip to content

Commit

Permalink
bump version to 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Dec 7, 2024
1 parent 255d90b commit 8c0f52a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "liplum/flarum-sync-profile-core",
"description": "The core module of user profile synchronization when authenticated by an external identity provider.",
"version": "0.1",
"version": "0.1.1",
"keywords": [
"flarum",
"flarum-extension",
Expand Down
4 changes: 2 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@liplum/flarum-sync-profile-core",
"private": true,
"version": "0.1",
"version": "0.1.1",
"devDependencies": {
"flarum-tsconfig": "^1.0",
"flarum-webpack-config": "^2.0",
Expand All @@ -13,4 +13,4 @@
"dev": "webpack --mode development --watch",
"build": "webpack --mode production"
}
}
}
34 changes: 13 additions & 21 deletions src/Listener/SyncProfileEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,27 @@

class SyncProfileEventListener
{
protected $avatarUploader;
protected $extensions;
protected $settings;
protected $container;
protected $config;
private $avatarUploader;
private $extensions;
private $settings;
private $container;
private $config;
private $log;

public function __construct(
Container $container,
AvatarUploader $avatarUploader,
ExtensionManager $extensions,
SettingsRepositoryInterface $settings,
Config $config,
LoggerInterface $log,
) {
$this->avatarUploader = $avatarUploader;
$this->extensions = $extensions;
$this->settings = $settings;
$this->container = $container;
$this->config = $config;
$this->log = $log;
}

public function subscribe(Dispatcher $events)
Expand All @@ -51,12 +54,12 @@ public function syncEvent(SyncProfileEvent $event)
$email = $event->email;
$user = User::query()->where("email", $email)->first();
if (!$user) {
$this->debugLog("Failed sync profile, due to $email not found");
$this->log->debug("Failed sync profile, due to $email not found");
return;
}
$this->sync($user, $event->attributes);
$user->save();
$this->debugLog("Synced $event->email");
$this->log->debug("Synced $event->email");
}

public function sync(User $user, $attributes)
Expand All @@ -71,7 +74,7 @@ public function sync(User $user, $attributes)
&& $nickname != $user->$nickname
) {
if (!$this->extensions->isEnabled('flarum-nicknames')) {
$this->debugLog("Sync user profile: 'nickname' failed, because extension 'flarum-nicknames' is not enabled.");
$this->log->debug("Sync user profile: 'nickname' failed, because extension 'flarum-nicknames' is not enabled.");
} else {
$user->nickname = $nickname;
}
Expand All @@ -86,7 +89,7 @@ public function sync(User $user, $attributes)
&& $bio != $user->bio
) {
if (!$this->extensions->isEnabled('fof-user-bio')) {
$this->debugLog("Sync user profile: 'nickname' failed, because extension 'fof/user-bio' is not enabled.");
$this->log->debug("Sync user profile: 'nickname' failed, because extension 'fof/user-bio' is not enabled.");
} else {
$user->bio = $bio;
}
Expand Down Expand Up @@ -136,7 +139,7 @@ public function sync(User $user, $attributes)
&& $this->settings->get('liplum-sync-profile-core.sync-masquerade', false)
) {
if (!$this->extensions->isEnabled('fof-masquerade')) {
$this->debugLog("Profile sync of of-masquerade failed, because extension 'fof/masquerade' is not enabled.");
$this->log->debug("Profile sync of of-masquerade failed, because extension 'fof/masquerade' is not enabled.");
} else {
$controller = UserConfigureController::class;
if (is_string($controller)) {
Expand Down Expand Up @@ -164,15 +167,4 @@ public function sync(User $user, $attributes)
}
}
}

protected function debugLog(string $message)
{
if ($this->config->inDebugMode()) {
/**
* @var LoggerInterface
*/
$logger = resolve(LoggerInterface::class);
$logger->info($message);
}
}
}

0 comments on commit 8c0f52a

Please sign in to comment.