Select alias when multiple matching identities

pull/169/head
M66B 5 years ago
parent 2153df6fc7
commit a0397e068a

@ -49,24 +49,23 @@ public interface DaoIdentity {
" ORDER BY name COLLATE NOCASE")
List<EntityIdentity> getIdentities(long account);
@Query("SELECT * FROM identity" +
" WHERE account = :account" +
" AND email = :email COLLATE NOCASE")
List<EntityIdentity> getIdentities(long account, String email);
@Query("SELECT identity.* FROM identity" +
" JOIN account ON account.id = identity.account" +
" WHERE identity.account = :account" +
" AND identity.synchronize AND account.synchronize")
List<EntityIdentity> getSynchronizingIdentities(long account);
@Query("SELECT * FROM identity WHERE id = :id")
EntityIdentity getIdentity(long id);
@Query("SELECT * FROM identity" +
" WHERE account = :account AND email = :email COLLATE NOCASE" +
" ORDER BY CASE WHEN synchronize THEN 0 ELSE 1 END" +
" LIMIT 1")
EntityIdentity getIdentity(long account, String email);
@Query("SELECT COUNT(*) FROM identity WHERE synchronize")
int getSynchronizingIdentityCount();
@Query("SELECT * FROM identity WHERE id = :id")
EntityIdentity getIdentity(long id);
@Insert
long insertIdentity(EntityIdentity identity);

@ -3915,7 +3915,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (message == null || message.identity == null)
return null;
return db.identity().getIdentity(message.identity);
EntityIdentity identity = db.identity().getIdentity(message.identity);
if (identity == null)
return null;
List<EntityIdentity> duplicates = db.identity().getIdentities(identity.account, identity.email);
if (duplicates == null || duplicates.size() > 1)
return null;
return identity;
}
@Override

Loading…
Cancel
Save