Close dangling groups cursor.
This commit is contained in:
parent
d90e3dc210
commit
1e2a27f902
1 changed files with 22 additions and 20 deletions
|
@ -66,33 +66,35 @@ public class IdentityUtil {
|
||||||
|
|
||||||
public static void markIdentityVerified(Context context, Recipient recipient, boolean verified, boolean remote)
|
public static void markIdentityVerified(Context context, Recipient recipient, boolean verified, boolean remote)
|
||||||
{
|
{
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
|
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
|
||||||
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
||||||
GroupDatabase.Reader reader = groupDatabase.getGroups();
|
|
||||||
|
|
||||||
GroupDatabase.GroupRecord groupRecord;
|
try (GroupDatabase.Reader reader = groupDatabase.getGroups()) {
|
||||||
|
|
||||||
while ((groupRecord = reader.getNext()) != null) {
|
GroupDatabase.GroupRecord groupRecord;
|
||||||
if (groupRecord.getMembers().contains(recipient.getId()) && groupRecord.isActive() && !groupRecord.isMms()) {
|
|
||||||
|
|
||||||
if (remote) {
|
while ((groupRecord = reader.getNext()) != null) {
|
||||||
IncomingTextMessage incoming = new IncomingTextMessage(recipient.getId(), 1, time, null, Optional.of(groupRecord.getEncodedId()), 0, false);
|
if (groupRecord.getMembers().contains(recipient.getId()) && groupRecord.isActive() && !groupRecord.isMms()) {
|
||||||
|
|
||||||
if (verified) incoming = new IncomingIdentityVerifiedMessage(incoming);
|
if (remote) {
|
||||||
else incoming = new IncomingIdentityDefaultMessage(incoming);
|
IncomingTextMessage incoming = new IncomingTextMessage(recipient.getId(), 1, time, null, Optional.of(groupRecord.getEncodedId()), 0, false);
|
||||||
|
|
||||||
smsDatabase.insertMessageInbox(incoming);
|
if (verified) incoming = new IncomingIdentityVerifiedMessage(incoming);
|
||||||
} else {
|
else incoming = new IncomingIdentityDefaultMessage(incoming);
|
||||||
RecipientId recipientId = DatabaseFactory.getRecipientDatabase(context).getOrInsertFromGroupId(groupRecord.getEncodedId());
|
|
||||||
Recipient groupRecipient = Recipient.resolved(recipientId);
|
|
||||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient);
|
|
||||||
OutgoingTextMessage outgoing ;
|
|
||||||
|
|
||||||
if (verified) outgoing = new OutgoingIdentityVerifiedMessage(recipient);
|
smsDatabase.insertMessageInbox(incoming);
|
||||||
else outgoing = new OutgoingIdentityDefaultMessage(recipient);
|
} else {
|
||||||
|
RecipientId recipientId = DatabaseFactory.getRecipientDatabase(context).getOrInsertFromGroupId(groupRecord.getEncodedId());
|
||||||
|
Recipient groupRecipient = Recipient.resolved(recipientId);
|
||||||
|
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(groupRecipient);
|
||||||
|
OutgoingTextMessage outgoing ;
|
||||||
|
|
||||||
DatabaseFactory.getSmsDatabase(context).insertMessageOutbox(threadId, outgoing, false, time, null);
|
if (verified) outgoing = new OutgoingIdentityVerifiedMessage(recipient);
|
||||||
|
else outgoing = new OutgoingIdentityDefaultMessage(recipient);
|
||||||
|
|
||||||
|
DatabaseFactory.getSmsDatabase(context).insertMessageOutbox(threadId, outgoing, false, time, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue