Update conversation timestamps for outgoing messages

This commit is contained in:
str4d
2016-07-12 12:28:41 +00:00
parent 2698e4c181
commit a6de1f7144
4 changed files with 22 additions and 4 deletions

View File

@@ -101,8 +101,7 @@ public abstract class ReadableMessageManagerImpl
BdfDictionary meta = new BdfDictionary();
meta.put(READ, read);
clientHelper.mergeMessageMetadata(txn, m, meta);
GroupId g = getContactGroup(db.getContact(txn, c)).getId();
updateGroupMetadata(txn, g, -1, local, wasRead, read);
updateContactMetadata(txn, c, -1, local, wasRead, read);
txn.setComplete();
} catch (FormatException e) {
throw new DbException(e);
@@ -111,7 +110,14 @@ public abstract class ReadableMessageManagerImpl
}
}
private void updateGroupMetadata(Transaction txn, GroupId groupId,
protected void updateContactMetadata(Transaction txn, ContactId contactId,
long timestamp, boolean local, boolean wasRead, boolean read)
throws DbException, FormatException {
GroupId g = getContactGroup(db.getContact(txn, contactId)).getId();
updateGroupMetadata(txn, g, timestamp, local, wasRead, read);
}
protected void updateGroupMetadata(Transaction txn, GroupId groupId,
long timestamp, boolean local, boolean wasRead, boolean read)
throws DbException, FormatException {
BdfDictionary groupMeta =

View File

@@ -310,6 +310,8 @@ class IntroductionManagerImpl extends ReadableMessageManagerImpl
Transaction txn = db.startTransaction(false);
try {
introducerManager.makeIntroduction(txn, c1, c2, msg, timestamp);
updateContactMetadata(txn, c1.getId(), timestamp, true, true, true);
updateContactMetadata(txn, c2.getId(), timestamp, true, true, true);
txn.setComplete();
} finally {
db.endTransaction(txn);
@@ -329,6 +331,7 @@ class IntroductionManagerImpl extends ReadableMessageManagerImpl
getSessionState(txn, g.getId(), sessionId.getBytes());
introduceeManager.acceptIntroduction(txn, state, timestamp);
updateContactMetadata(txn, contactId, timestamp, true, true, true);
txn.setComplete();
} finally {
db.endTransaction(txn);
@@ -348,6 +351,7 @@ class IntroductionManagerImpl extends ReadableMessageManagerImpl
getSessionState(txn, g.getId(), sessionId.getBytes());
introduceeManager.declineIntroduction(txn, state, timestamp);
updateContactMetadata(txn, contactId, timestamp, true, true, true);
txn.setComplete();
} finally {
db.endTransaction(txn);

View File

@@ -116,6 +116,7 @@ class MessagingManagerImpl extends ReadableMessageManagerImpl
@Override
public void addLocalMessage(PrivateMessage m) throws DbException {
Transaction txn = db.startTransaction(false);
try {
BdfDictionary meta = new BdfDictionary();
meta.put(TIMESTAMP, m.getMessage().getTimestamp());
@@ -123,9 +124,15 @@ class MessagingManagerImpl extends ReadableMessageManagerImpl
meta.put("contentType", m.getContentType());
meta.put(LOCAL, true);
meta.put(READ, true);
clientHelper.addLocalMessage(m.getMessage(), CLIENT_ID, meta, true);
clientHelper.addLocalMessage(txn, m.getMessage(), CLIENT_ID, meta,
true);
updateGroupMetadata(txn, m.getMessage().getGroupId(),
m.getMessage().getTimestamp(), true, true, true);
txn.setComplete();
} catch (FormatException e) {
throw new RuntimeException(e);
} finally {
db.endTransaction(txn);
}
}

View File

@@ -872,6 +872,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IM
messageQueueManager
.sendMessage(txn, group, timestamp, body, meta);
updateGroupMetadata(txn, m.getGroupId(), timestamp, true, true, true);
}
@Override