GroupsV2: Use both sent_at and received_at when processing changes

This commit is contained in:
Scott Nonnenberg 2020-09-10 14:04:45 -07:00 committed by GitHub
parent deb3dd5d4e
commit cad9803d38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -2463,7 +2463,8 @@
conversation,
groupChangeBase64: groupChange,
newRevision: revision,
timestamp: message.get('received_at'),
receivedAt: message.get('received_at'),
sentAt: message.get('sent_at'),
});
} catch (error) {
const errorText = error && error.stack ? error.stack : error;

View file

@ -268,7 +268,8 @@ type MaybeUpdatePropsType = {
conversation: ConversationModelType;
groupChangeBase64?: string;
newRevision?: number;
timestamp?: number;
receivedAt?: number;
sentAt?: number;
dropInitialJoinMessage?: boolean;
};
@ -294,10 +295,11 @@ export async function waitThenMaybeUpdateGroup(options: MaybeUpdatePropsType) {
export async function maybeUpdateGroup({
conversation,
dropInitialJoinMessage,
groupChangeBase64,
newRevision,
timestamp,
dropInitialJoinMessage,
receivedAt,
sentAt,
}: MaybeUpdatePropsType) {
const logId = conversation.idForLogging();
@ -321,8 +323,8 @@ export async function maybeUpdateGroup({
// Ensure that all generated message are ordered properly. Before the provided timestamp
// so update messages appear before the initiating message, or after now().
let syntheticTimestamp = timestamp
? timestamp - (groupChangeMessages.length + 1)
let syntheticTimestamp = receivedAt
? receivedAt - (groupChangeMessages.length + 1)
: Date.now();
// Save all synthetic messages describing group changes
const changeMessagesToSave = groupChangeMessages.map(changeMessage => {
@ -333,6 +335,7 @@ export async function maybeUpdateGroup({
...changeMessage,
conversationId: conversation.id,
received_at: syntheticTimestamp,
sent_at: sentAt,
};
});