Force save for call disposition
This commit is contained in:
parent
a779542d10
commit
58f4082c4a
2 changed files with 74 additions and 3 deletions
|
@ -3251,7 +3251,8 @@ export class ConversationModel extends window.Backbone
|
||||||
endedTime,
|
endedTime,
|
||||||
} = callHistoryDetails;
|
} = callHistoryDetails;
|
||||||
log.info(
|
log.info(
|
||||||
`addCallHistory: Call ID: ${callId}, ` +
|
`addCallHistory: Conversation ID: ${this.id}, ` +
|
||||||
|
`Call ID: ${callId}, ` +
|
||||||
'Direct, ' +
|
'Direct, ' +
|
||||||
`Incoming: ${wasIncoming}, ` +
|
`Incoming: ${wasIncoming}, ` +
|
||||||
`Video: ${wasVideoCall}, ` +
|
`Video: ${wasVideoCall}, ` +
|
||||||
|
@ -3306,20 +3307,23 @@ export class ConversationModel extends window.Backbone
|
||||||
);
|
);
|
||||||
if (messageId != null) {
|
if (messageId != null) {
|
||||||
log.info(
|
log.info(
|
||||||
`addCallHistory: Found existing call history message (Call ID ${callHistoryDetails.callId}, Message ID: ${messageId})`
|
`addCallHistory: Found existing call history message (Call ID: ${callHistoryDetails.callId}, Message ID: ${messageId})`
|
||||||
);
|
);
|
||||||
message.id = messageId;
|
message.id = messageId;
|
||||||
} else {
|
} else {
|
||||||
log.info(
|
log.info(
|
||||||
`addCallHistory: No existing call history message found (Call ID ${callHistoryDetails.callId})`
|
`addCallHistory: No existing call history message found (Call ID: ${callHistoryDetails.callId})`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = await window.Signal.Data.saveMessage(message, {
|
const id = await window.Signal.Data.saveMessage(message, {
|
||||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||||
|
forceSave: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
log.info(`addCallHistory: Saved call history message (ID: ${id})`);
|
||||||
|
|
||||||
const model = window.MessageController.register(
|
const model = window.MessageController.register(
|
||||||
id,
|
id,
|
||||||
new window.Whisper.Message({
|
new window.Whisper.Message({
|
||||||
|
|
67
ts/test-electron/sql/getCallHistoryMessageByCallId_test.ts
Normal file
67
ts/test-electron/sql/getCallHistoryMessageByCallId_test.ts
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
// Copyright 2023 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { assert } from 'chai';
|
||||||
|
|
||||||
|
import dataInterface from '../../sql/Client';
|
||||||
|
import { UUID } from '../../types/UUID';
|
||||||
|
import type { UUIDStringType } from '../../types/UUID';
|
||||||
|
|
||||||
|
import type { MessageAttributesType } from '../../model-types.d';
|
||||||
|
import { CallMode } from '../../types/Calling';
|
||||||
|
|
||||||
|
const {
|
||||||
|
removeAll,
|
||||||
|
_getAllMessages,
|
||||||
|
saveMessages,
|
||||||
|
getCallHistoryMessageByCallId,
|
||||||
|
} = dataInterface;
|
||||||
|
|
||||||
|
function getUuid(): UUIDStringType {
|
||||||
|
return UUID.generate().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('sql/getCallHistoryMessageByCallId', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await removeAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a previous call history message', async () => {
|
||||||
|
assert.lengthOf(await _getAllMessages(), 0);
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const conversationId = getUuid();
|
||||||
|
const ourUuid = getUuid();
|
||||||
|
|
||||||
|
const callHistoryMessage: MessageAttributesType = {
|
||||||
|
id: getUuid(),
|
||||||
|
type: 'call-history',
|
||||||
|
conversationId,
|
||||||
|
sent_at: now - 10,
|
||||||
|
received_at: now - 10,
|
||||||
|
timestamp: now - 10,
|
||||||
|
callHistoryDetails: {
|
||||||
|
callId: '12345',
|
||||||
|
callMode: CallMode.Direct,
|
||||||
|
wasIncoming: true,
|
||||||
|
wasVideoCall: true,
|
||||||
|
wasDeclined: true,
|
||||||
|
acceptedTime: now - 10,
|
||||||
|
endedTime: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
await saveMessages([callHistoryMessage], {
|
||||||
|
forceSave: true,
|
||||||
|
ourUuid,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.lengthOf(await _getAllMessages(), 1);
|
||||||
|
|
||||||
|
const messageId = await getCallHistoryMessageByCallId(
|
||||||
|
conversationId,
|
||||||
|
'12345'
|
||||||
|
);
|
||||||
|
assert.strictEqual(messageId, callHistoryMessage.id);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue