mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Drop pni call messages
This commit is contained in:
@@ -139,7 +139,7 @@ import {
|
||||
} from '../util/callDisposition';
|
||||
import { isNormalNumber } from '../util/isNormalNumber';
|
||||
import type { AciString, ServiceIdString } from '../types/ServiceId';
|
||||
import { isServiceIdString } from '../types/ServiceId';
|
||||
import { isServiceIdString, isPniString } from '../types/ServiceId';
|
||||
import { isSignalConnection } from '../util/getSignalConnections';
|
||||
import { toAdminKeyBytes } from '../util/callLinks';
|
||||
import {
|
||||
@@ -2839,6 +2839,14 @@ export class CallingClass {
|
||||
callingMessage.offer &&
|
||||
!conversation.getAccepted({ ignoreEmptyConvo: true })
|
||||
) {
|
||||
if (isPniString(envelope.destinationServiceId)) {
|
||||
log.info(
|
||||
`${logId}: Conversation was not approved by user; ` +
|
||||
'ignoring call message on PNI.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(
|
||||
`${logId}: Conversation was not approved by user; ` +
|
||||
'rejecting call message.'
|
||||
|
||||
98
ts/test-mock/pnp/calling_test.ts
Normal file
98
ts/test-mock/pnp/calling_test.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import chai, { assert } from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import { type PrimaryDevice, ServiceIdKind } from '@signalapp/mock-server';
|
||||
import createDebug from 'debug';
|
||||
|
||||
import * as durations from '../../util/durations';
|
||||
import { Bootstrap } from '../bootstrap';
|
||||
import type { App } from '../bootstrap';
|
||||
import { acceptConversation } from '../helpers';
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
export const debug = createDebug('mock:test:pnp:calling');
|
||||
|
||||
describe('pnp/calling', function (this: Mocha.Suite) {
|
||||
this.timeout(durations.MINUTE);
|
||||
|
||||
let bootstrap: Bootstrap;
|
||||
let app: App;
|
||||
let alice: PrimaryDevice;
|
||||
let stranger: PrimaryDevice;
|
||||
|
||||
beforeEach(async () => {
|
||||
bootstrap = new Bootstrap({ contactCount: 0 });
|
||||
await bootstrap.init();
|
||||
|
||||
const { server } = bootstrap;
|
||||
|
||||
alice = await server.createPrimaryDevice({
|
||||
profileName: 'Alice',
|
||||
});
|
||||
stranger = await server.createPrimaryDevice({
|
||||
profileName: 'Stranger',
|
||||
});
|
||||
|
||||
app = await bootstrap.link();
|
||||
|
||||
const { desktop } = bootstrap;
|
||||
|
||||
const ourPniKey = await desktop.popSingleUseKey(ServiceIdKind.PNI);
|
||||
await stranger.addSingleUseKey(desktop, ourPniKey, ServiceIdKind.PNI);
|
||||
|
||||
const ourAciKey = await desktop.popSingleUseKey(ServiceIdKind.ACI);
|
||||
await alice.addSingleUseKey(desktop, ourAciKey, ServiceIdKind.ACI);
|
||||
});
|
||||
|
||||
afterEach(async function (this: Mocha.Context) {
|
||||
await bootstrap.maybeSaveLogs(this.currentTest, app);
|
||||
await app.close();
|
||||
await bootstrap.teardown();
|
||||
});
|
||||
|
||||
it('should ignore calling message received on PNI', async () => {
|
||||
const { desktop } = bootstrap;
|
||||
|
||||
const window = await app.getWindow();
|
||||
const leftPane = window.locator('#LeftPane');
|
||||
|
||||
debug('Sending a calling message from stranger to PNI');
|
||||
await stranger.sendRaw(
|
||||
desktop,
|
||||
{
|
||||
callMessage: {
|
||||
offer: {
|
||||
opaque: Buffer.alloc(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: bootstrap.getTimestamp(),
|
||||
serviceIdKind: ServiceIdKind.PNI,
|
||||
}
|
||||
);
|
||||
|
||||
debug('Sending a message from a known contact');
|
||||
await alice.sendText(desktop, 'hey', {
|
||||
withProfileKey: true,
|
||||
});
|
||||
|
||||
debug('Open conversation with a known contact');
|
||||
await leftPane.locator(`[data-testid="${alice.toContact().aci}"]`).click();
|
||||
|
||||
debug('Accept conversation from a known contact');
|
||||
await acceptConversation(window);
|
||||
|
||||
debug('Wait for a message from a known contact');
|
||||
await alice.waitForMessage();
|
||||
|
||||
debug('Verify no session with stranger');
|
||||
await assert.isRejected(
|
||||
stranger.sendText(desktop, 'Hello on ACI'),
|
||||
/session with.*not found/
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user