Skip to content

Commit

Permalink
#1503 dupicates on upsync: better handling of lost ACLs -> remove mis…
Browse files Browse the repository at this point in the history
…sing users from cards
  • Loading branch information
desperateCoder committed Nov 21, 2024
1 parent ef6df0e commit 7568a20
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
import it.niedermann.nextcloud.deck.ui.upcomingcards.UpcomingCardsAdapterItem;
import it.niedermann.nextcloud.deck.ui.widget.singlecard.SingleCardWidget;
import it.niedermann.nextcloud.deck.util.ExecutorServiceProvider;
import okhttp3.Headers;

public class DataBaseAdapter {
@NonNull
Expand Down Expand Up @@ -485,6 +484,10 @@ public void deleteJoinedUserForCardPhysically(long localCardId, long localUserId
db.getJoinCardWithUserDao().deleteByCardIdAndUserIdPhysically(localCardId, localUserId);
}

public void deleteJoinedUsersForCardsInBoardPhysically(long localBoardId) {
db.getJoinCardWithUserDao().deleteJoinedUsersForCardsInBoardPhysically(localBoardId);
}

public void createJoinCardWithUser(long localUserId, long localCardId) {
createJoinCardWithUser(localUserId, localCardId, DBStatus.UP_TO_DATE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public interface JoinCardWithUserDao extends GenericDao<JoinCardWithUser> {
@Query("DELETE FROM joincardwithuser WHERE cardId = :localCardId and userId = :localUserId")
void deleteByCardIdAndUserIdPhysically(long localCardId, long localUserId);

@Query("DELETE FROM joincardwithuser " +
"WHERE cardid in (select c.localId from Card c join Stack s on c.stackId = s.localId and s.boardId = :localBoardId) " +
"and userId not in (select userId from UserInBoard where boardId = :localBoardId)")
void deleteJoinedUsersForCardsInBoardPhysically(long localBoardId);

@Query("select * FROM joincardwithuser WHERE cardId = :localCardId and userId = :localUserId")
JoinCardWithUser getJoin(Long localUserId, Long localCardId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private void handleUsers(DataBaseAdapter dataBaseAdapter, long accountId, FullBo
dataBaseAdapter.addUserToBoard(existing.getLocalId(), entity.getLocalId());
}
}
dataBaseAdapter.deleteJoinedUsersForCardsInBoardPhysically(entity.getLocalId());
}

private User createOrUpdateUser(DataBaseAdapter dataBaseAdapter, long accountId, User remoteUser) {
Expand Down

0 comments on commit 7568a20

Please sign in to comment.