Commit 59e50c27 authored by Guy Thouret's avatar Guy Thouret

(feat) Split state change view to separate views for increasing and decreasing user state - #589

1 merge request!285WIP: Reward Factors for User Activity
Pipeline #73232898 failed with stages
in 3 minutes and 56 seconds
......@@ -26,10 +26,8 @@ class UpdateUserState
public function update(): void
{
if ($this->user->getUserState() !== $this->userState->getState()) {
$this->updateUserEntity();
$this->sendStateChangeNotification();
}
$this->updateUserEntity();
$this->sendStateChangeNotification();
}
private function updateUserEntity(): void
......@@ -41,14 +39,17 @@ class UpdateUserState
private function sendStateChangeNotification(): void
{
Dispatcher::trigger('notification', 'reward', [
'to'=> [
$this->userState->getUserGuid()
],
'from' => Notification::SYSTEM_ENTITY,
'notification_view' => 'rewards_state_change',
'params' => $this->userState->export()
]);
if ($this->userState->getStateChange() !== 0) {
$notificationView = ($this->userState->getStateChange() > 0) ?
'reward_state_increase' : 'reward_state_decrease';
Dispatcher::trigger('notification', 'reward', [
'to' => [
$this->userState->getUserGuid()
],
'from' => Notification::SYSTEM_ENTITY,
'notification_view' => $notificationView,
'params' => $this->userState->export()
]);
}
}
}
......@@ -23,7 +23,7 @@ use Minds\Traits\MagicAttributes;
* @method UserState setActivityPercentage(float $activityPercentage)
* @method float getActivityPercentage()
* @method UserState setStateChange(int $stateChange)
* @method int getUserState()
* @method int getStateChange()
*/
class UserState
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment