Fix repeated call messages for timestamp updates

This commit is contained in:
Jamie Kyle 2024-11-19 16:04:34 -08:00 committed by GitHub
parent 6bf7151745
commit 8cb80f66dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1497,38 +1497,46 @@ export async function updateLocalGroupCallHistoryTimestamp(
if (conversation == null) { if (conversation == null) {
return null; return null;
} }
const peerId = getPeerIdFromConversation(conversation.attributes);
const prevCallHistory = return conversation.queueJob<CallHistoryDetails | null>(
(await DataReader.getCallHistory(callId, peerId)) ?? null; 'updateLocalGroupCallHistoryTimestamp',
async () => {
const peerId = getPeerIdFromConversation(conversation.attributes);
// We don't have all the details to add new call history here const prevCallHistory =
if (prevCallHistory != null) { (await DataReader.getCallHistory(callId, peerId)) ?? null;
log.info(
'updateLocalGroupCallHistoryTimestamp: Found previous call history:',
formatCallHistory(prevCallHistory)
);
} else {
log.info('updateLocalGroupCallHistoryTimestamp: No previous call history');
return null;
}
if (timestamp >= prevCallHistory.timestamp) { // We don't have all the details to add new call history here
log.info( if (prevCallHistory != null) {
'updateLocalGroupCallHistoryTimestamp: New timestamp is later than existing call history, ignoring' log.info(
); 'updateLocalGroupCallHistoryTimestamp: Found previous call history:',
return prevCallHistory; formatCallHistory(prevCallHistory)
} );
} else {
log.info(
'updateLocalGroupCallHistoryTimestamp: No previous call history'
);
return null;
}
const updatedCallHistory = await saveCallHistory({ if (timestamp >= prevCallHistory.timestamp) {
callHistory: { log.info(
...prevCallHistory, 'updateLocalGroupCallHistoryTimestamp: New timestamp is later than existing call history, ignoring'
timestamp, );
}, return prevCallHistory;
conversation, }
receivedAtCounter: null,
receivedAtMS: null,
});
return updatedCallHistory; const updatedCallHistory = await saveCallHistory({
callHistory: {
...prevCallHistory,
timestamp,
},
conversation,
receivedAtCounter: null,
receivedAtMS: null,
});
return updatedCallHistory;
}
);
} }