Fix MessageRequestResponse sync processing
This commit is contained in:
parent
94f02dcc88
commit
943518dc3a
2 changed files with 80 additions and 10 deletions
|
@ -74,4 +74,70 @@ describe('unknown contacts', function (this: Mocha.Suite) {
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('blocks incoming calls from unknown contacts & shows message request', async () => {
|
||||||
|
const { desktop } = bootstrap;
|
||||||
|
|
||||||
|
debug('sending calling offer message');
|
||||||
|
await unknownContact.sendRaw(desktop, {
|
||||||
|
callingMessage: {
|
||||||
|
offer: {
|
||||||
|
callId: new Long(Math.floor(Math.random() * 1e10)),
|
||||||
|
type: Proto.CallingMessage.Offer.Type.OFFER_AUDIO_CALL,
|
||||||
|
opaque: new Uint8Array(0),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
debug('opening conversation');
|
||||||
|
const leftPane = page.locator('#LeftPane');
|
||||||
|
|
||||||
|
const conversationListItem = leftPane.getByRole('button', {
|
||||||
|
name: 'Chat with Unknown contact',
|
||||||
|
});
|
||||||
|
await conversationListItem.getByText('Message Request').click();
|
||||||
|
|
||||||
|
const conversationStack = page.locator('.Inbox__conversation-stack');
|
||||||
|
await conversationStack.getByText('Missed voice call').waitFor();
|
||||||
|
|
||||||
|
debug('accepting message request');
|
||||||
|
await page.getByText('message you and share your name').waitFor();
|
||||||
|
await page.getByRole('button', { name: 'Accept' }).click();
|
||||||
|
assert.strictEqual(
|
||||||
|
await page.getByText('message you and share your name').count(),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('syncs message request state', async () => {
|
||||||
|
const { phone, desktop } = bootstrap;
|
||||||
|
|
||||||
|
debug('sending regular text message');
|
||||||
|
await unknownContact.sendText(desktop, 'hello');
|
||||||
|
|
||||||
|
debug('opening conversation');
|
||||||
|
const leftPane = page.locator('#LeftPane');
|
||||||
|
|
||||||
|
const conversationListItem = leftPane.getByRole('button', {
|
||||||
|
name: 'Chat with Unknown contact',
|
||||||
|
});
|
||||||
|
await conversationListItem.getByText('Message Request').click();
|
||||||
|
|
||||||
|
debug('sending message request sync');
|
||||||
|
await phone.sendRaw(desktop, {
|
||||||
|
syncMessage: {
|
||||||
|
messageRequestResponse: {
|
||||||
|
type: Proto.SyncMessage.MessageRequestResponse.Type.ACCEPT,
|
||||||
|
threadAci: unknownContact.device.aci,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
debug('verifying that compose is now visible');
|
||||||
|
const composeArea = page.locator(
|
||||||
|
'.composition-area-wrapper, .Inbox__conversation .ConversationView'
|
||||||
|
);
|
||||||
|
const input = composeArea.locator('[data-testid=CompositionInput]');
|
||||||
|
await input.waitFor();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2899,11 +2899,13 @@ export default class MessageReceiver
|
||||||
const { groupId, timestamp, action } = typingMessage;
|
const { groupId, timestamp, action } = typingMessage;
|
||||||
|
|
||||||
let groupV2IdString: string | undefined;
|
let groupV2IdString: string | undefined;
|
||||||
if (groupId && groupId.byteLength === GROUPV2_ID_LENGTH) {
|
if (groupId?.byteLength) {
|
||||||
|
if (groupId.byteLength === GROUPV2_ID_LENGTH) {
|
||||||
groupV2IdString = Bytes.toBase64(groupId);
|
groupV2IdString = Bytes.toBase64(groupId);
|
||||||
} else {
|
} else {
|
||||||
log.error('handleTypingMessage: Received invalid groupId value');
|
log.error('handleTypingMessage: Received invalid groupId value');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new TypingEvent({
|
new TypingEvent({
|
||||||
|
@ -3241,13 +3243,15 @@ export default class MessageReceiver
|
||||||
const { groupId } = sync;
|
const { groupId } = sync;
|
||||||
|
|
||||||
let groupV2IdString: string | undefined;
|
let groupV2IdString: string | undefined;
|
||||||
if (groupId && groupId.byteLength === GROUPV2_ID_LENGTH) {
|
if (groupId?.byteLength) {
|
||||||
|
if (groupId.byteLength === GROUPV2_ID_LENGTH) {
|
||||||
groupV2IdString = Bytes.toBase64(groupId);
|
groupV2IdString = Bytes.toBase64(groupId);
|
||||||
} else {
|
} else {
|
||||||
this.removeFromCache(envelope);
|
this.removeFromCache(envelope);
|
||||||
log.error('Received message request with invalid groupId');
|
log.error('Received message request with invalid groupId');
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ev = new MessageRequestResponseEvent(
|
const ev = new MessageRequestResponseEvent(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue