mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2026-01-03 03:27:28 +01:00
fixed bug when monitoring uses wrong username to show it to a user
This commit is contained in:
@@ -265,11 +265,13 @@ class DataRepository(@Autowired em: EntityManager) {
|
||||
.toSeq
|
||||
}
|
||||
|
||||
def getUsernameById(userId: Long): Option[String] = {
|
||||
def getUsernameByUserIdAndAccountId(userId: Long, accountId: Long): Option[String] = {
|
||||
em.createQuery(
|
||||
"select credentials.username from Credentials credentials where credentials.userId = :userId",
|
||||
"""select credentials.username from Credentials credentials where credentials.userId = :userId
|
||||
| and credentials.accountId = :accountId""".stripMargin,
|
||||
classOf[String]
|
||||
).setParameter("userId", userId)
|
||||
.setParameter("accountId", accountId)
|
||||
.getResultList
|
||||
.asScala
|
||||
.headOption
|
||||
|
||||
@@ -84,7 +84,7 @@ class DataService {
|
||||
for {
|
||||
userId <- dataRepository.findUserId(source.chatId, source.sourceSystem.id).map(_.toLong)
|
||||
accountId <- dataRepository.findAccountId(userId).map(_.toLong)
|
||||
username <- dataRepository.getUsernameById(userId)
|
||||
username <- dataRepository.getUsernameByUserIdAndAccountId(userId, accountId)
|
||||
} yield (userId, username, accountId)
|
||||
}
|
||||
|
||||
@@ -96,10 +96,6 @@ class DataService {
|
||||
dataRepository.getUserCredentials(userId)
|
||||
}
|
||||
|
||||
def getUsernameById(userId: Long): Option[String] = {
|
||||
dataRepository.getUsernameById(userId)
|
||||
}
|
||||
|
||||
def findUserCredentialsByAccountId(userId: Long, accountId: Long): Option[Credentials] = {
|
||||
dataRepository.findUserCredentialsByUserIdAndAccountId(userId, accountId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user