Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authordesperateCoder <echotodevnull@gmail.com>2019-10-19 23:35:49 +0300
committerdesperateCoder <echotodevnull@gmail.com>2019-10-19 23:35:55 +0300
commit7ab0e6cfc15a271368679e51b2298ae9cb7f1ce7 (patch)
tree57be9a27cc0b348c158b5c06b515d31c610cfeb6 /app/src
parent6cb91f0d137f423af4703093673b70edb0a5911f (diff)
#148: search and proposal queries for ACL
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/UserDao.java38
1 files changed, 11 insertions, 27 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/UserDao.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/UserDao.java
index fe3b78826..ae2db5652 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/UserDao.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/dao/UserDao.java
@@ -29,14 +29,13 @@ public interface UserDao extends GenericDao<User> {
"and ( uid LIKE :searchTerm or displayname LIKE :searchTerm or primaryKey LIKE :searchTerm )")
LiveData<List<User>> searchUserByUidOrDisplayName(final long accountId, final long notYetAssignedToLocalCardId, final String searchTerm);
- // TODO @desperateCoder exclude all which are already in the ACL for the given boardId
@Query("SELECT u.* FROM user u WHERE accountId = :accountId " +
" AND NOT EXISTS (" +
- " select 1 from joincardwithuser ju" +
- " where ju.userId = u.localId" +
- " )" +
+ " select 1 from accesscontrol ju" +
+ " where ju.userId = u.localId and ju.boardId = :boardId and status <> 3" + // not LOCAL_DELETED
+ " ) " +
"and ( uid LIKE :searchTerm or displayname LIKE :searchTerm or primaryKey LIKE :searchTerm )")
- LiveData<List<User>> searchUserByUidOrDisplayNameForACL(final long accountId/*, final long boardId*/, final String searchTerm);
+ LiveData<List<User>> searchUserByUidOrDisplayNameForACL(final long accountId, final long boardId, final String searchTerm);
@Query("SELECT * FROM user WHERE accountId = :accountId and uid = :uid")
User getUserByUidDirectly(final long accountId, final String uid);
@@ -72,29 +71,14 @@ public interface UserDao extends GenericDao<User> {
" LIMIT :topX")
LiveData<List<User>> findProposalsForUsersToAssign(long accountId, long boardId, long notAssignedToLocalCardId, int topX);
- // TODO @desperateCoder exclude all which are already in the ACL for the given boardId
- @Query(" SELECT u.* FROM user u" +
- " WHERE u.accountId = :accountId" +
+
+ @Query("SELECT u.* FROM user u WHERE accountId = :accountId " +
" AND NOT EXISTS (" +
- " select 1 from joincardwithuser ju" +
- " where ju.userId = u.localId" +
- " )" +
- " AND" +
- " (" +
- " EXISTS (" +
- " select 1 from accesscontrol" +
- " where userId = u.localId and boardId = :boardId" +
- " )" +
- " OR" +
- " EXISTS (" +
- " select 1 from board where localId = :boardId AND ownerId = u.localId" +
- " )" +
- ")" +
- " ORDER BY (" +
- " select count(*) from joincardwithuser j" +
- " where userId = u.localId and cardId in (select c.localId from card c inner join stack s on s.localId = c.stackId where s.boardId = :boardId)" +
- ") DESC" +
- " LIMIT :topX")
+ " select 1 from accesscontrol ju" +
+ " where ju.userId = u.localId and ju.boardId = :boardId and status <> 3" + // not LOCAL_DELETED
+ " ) " +
+ "ORDER BY u.displayname " +
+ "LIMIT :topX")
LiveData<List<User>> findProposalsForUsersToAssignForACL(long accountId, long boardId, int topX);