Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Feature: find valid
Browse files Browse the repository at this point in the history
  • Loading branch information
hqy2000 committed Jul 25, 2018
1 parent 97450f4 commit 54ff42e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Repository/User/DeviceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ public function findByUserAndType(User $user, int $type) {
return $this->findBy(["user" => $user, "type" => $type]);
}

public function findValidByUserAndType(User $user, int $type) {
return $this->createQueryBuilder("u")
->where("u.user = :user")
->andWhere("u.type = :type")
->andWhere("u.status > :status")
->setParameter("user", $user)
->setParameter("type", $type)
->setParameter("status", -1)
->getQuery()
->getResult();
}

public function findByType(int $type) {
return $this->findBy(["type" => $type]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function notifyNewMessage(Chat $chat) {
}

private function getDevices(User $user) {
return $this->objectManager->getRepository(Device::class)->findByUserAndType($user, DeviceType::IOS);
return $this->objectManager->getRepository(Device::class)->findValidByUserAndType($user, DeviceType::IOS, true);
}

private function isPhoneUsed(?string $phone) {
Expand Down

0 comments on commit 54ff42e

Please sign in to comment.