Skip to content

Commit

Permalink
try to fix transaction handling
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuly committed Jun 11, 2020
1 parent 88fc67f commit 6037861
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package net.folivo.matrix.bridge.sms.room
import org.neo4j.springframework.data.repository.query.Query
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional
import reactor.core.publisher.Flux

@Repository
interface AppserviceRoomRepository : ReactiveCrudRepository<AppserviceRoom, String> {

@Transactional
@Query(
"MATCH (user:AppserviceUser)-[:MEMBER_OF]->(room:AppserviceRoom) " +
"WHERE user.userId in \$members " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class SmsMatrixAppserviceRoomService(
}
}


fun getRoomOrCreateAndJoin(roomId: String, userId: String): Mono<AppserviceRoom> {
return roomRepository.findById(roomId)
.switchIfEmpty(Mono.defer { saveRoomJoinAndGet(roomId, userId) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package net.folivo.matrix.bridge.sms.user
import org.neo4j.springframework.data.repository.query.Query
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional
import reactor.core.publisher.Mono

@Repository
interface AppserviceUserRepository : ReactiveCrudRepository<AppserviceUser, String> {

@Transactional
@Query("MATCH (:AppserviceRoom) <- [m:MEMBER_OF] - (:AppserviceUser {userId:\$userId}) WITH max(m.mappingToken) as maxi WHERE NOT maxi IS NULL RETURN maxi")
fun findLastMappingTokenByUserId(userId: String): Mono<Int>

Expand Down

0 comments on commit 6037861

Please sign in to comment.