Fix repeated call messages for timestamp updates
This commit is contained in:
parent
6bf7151745
commit
8cb80f66dc
1 changed files with 37 additions and 29 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue