Skip to content

Commit

Permalink
don't send message if user already bought new license
Browse files Browse the repository at this point in the history
  • Loading branch information
g5bot committed Dec 10, 2023
1 parent e052c90 commit b025398
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/Module/Maintenance/OldTradeLicenseDeletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,25 @@ private function deleteExpiredLicenses(): array
foreach ($licensesToDelete as $license) {
$latestLicenseInfo = $this->tradeLicenseInfoRepository->getLatestLicenseInfo($license->getTradePostId());

// send message to user
$this->privateMessageSender->send(
UserEnum::USER_NOONE,
$license->getUser()->getId(),
sprintf(
"Deine Lizenz am Handelsposten %s ist abgelaufen.\nEine neue Lizenz kostet dort aktuell %d %s.",
$license->getTradePost()->getName(),
$latestLicenseInfo->getAmount(),
$latestLicenseInfo->getCommodity()->getName()
),
PrivateMessageFolderSpecialEnum::PM_SPECIAL_SYSTEM
);
$userId = $license->getUser()->getId();
$tradePost = $license->getTradePost();

$userHasLicense = $this->tradeLicenseRepository->hasLicenseByUserAndTradePost($userId, $tradePost->getId());
if (!$userHasLicense) {

// send message to user
$this->privateMessageSender->send(
UserEnum::USER_NOONE,
$userId,
sprintf(
"Deine Lizenz am Handelsposten %s ist abgelaufen.\nEine neue Lizenz kostet dort aktuell %d %s.",
$tradePost->getName(),
$latestLicenseInfo->getAmount(),
$latestLicenseInfo->getCommodity()->getName()
),
PrivateMessageFolderSpecialEnum::PM_SPECIAL_SYSTEM
);
}

$this->tradeLicenseRepository->delete($license);
}
Expand Down

0 comments on commit b025398

Please sign in to comment.