Don't accept PNI as ACI in contact sync
This commit is contained in:
parent
da113c1fa1
commit
ca45a9cf74
3 changed files with 46 additions and 26 deletions
|
@ -54,6 +54,7 @@ import {
|
||||||
toTaggedPni,
|
toTaggedPni,
|
||||||
} from '../types/ServiceId';
|
} from '../types/ServiceId';
|
||||||
import { normalizeAci } from '../util/normalizeAci';
|
import { normalizeAci } from '../util/normalizeAci';
|
||||||
|
import { isAciString } from '../util/isAciString';
|
||||||
import * as Stickers from '../types/Stickers';
|
import * as Stickers from '../types/Stickers';
|
||||||
import type {
|
import type {
|
||||||
StoryDistributionWithMembersType,
|
StoryDistributionWithMembersType,
|
||||||
|
@ -997,6 +998,11 @@ export async function mergeContactRecord(
|
||||||
return { hasConflict: false, shouldDrop: true, details: ['no uuid'] };
|
return { hasConflict: false, shouldDrop: true, details: ['no uuid'] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Contacts should not have PNI as ACI
|
||||||
|
if (aci && !isAciString(aci)) {
|
||||||
|
return { hasConflict: false, shouldDrop: true, details: ['invalid aci'] };
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
window.storage.user.getOurServiceIdKind(serviceId) !== ServiceIdKind.Unknown
|
window.storage.user.getOurServiceIdKind(serviceId) !== ServiceIdKind.Unknown
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import protobuf from '../protobuf/wrap';
|
||||||
|
|
||||||
import { SignalService as Proto } from '../protobuf';
|
import { SignalService as Proto } from '../protobuf';
|
||||||
import { normalizeAci } from '../util/normalizeAci';
|
import { normalizeAci } from '../util/normalizeAci';
|
||||||
|
import { isAciString } from '../util/isAciString';
|
||||||
import { DurationInSeconds } from '../util/durations';
|
import { DurationInSeconds } from '../util/durations';
|
||||||
import * as Errors from '../types/errors';
|
import * as Errors from '../types/errors';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
@ -115,6 +116,7 @@ export class ContactBuffer extends ParserBase<
|
||||||
}
|
}
|
||||||
|
|
||||||
public override next(): ModifiedContactDetails | undefined {
|
public override next(): ModifiedContactDetails | undefined {
|
||||||
|
while (this.reader.pos < this.reader.len) {
|
||||||
const proto = this.decodeDelimited();
|
const proto = this.decodeDelimited();
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -126,6 +128,13 @@ export class ContactBuffer extends ParserBase<
|
||||||
|
|
||||||
const { verified } = proto;
|
const { verified } = proto;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isAciString(proto.aci) ||
|
||||||
|
(verified?.destinationAci && !isAciString(verified.destinationAci))
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...proto,
|
...proto,
|
||||||
|
|
||||||
|
@ -144,4 +153,7 @@ export class ContactBuffer extends ParserBase<
|
||||||
aci: normalizeAci(proto.aci, 'ContactBuffer.aci'),
|
aci: normalizeAci(proto.aci, 'ContactBuffer.aci'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import type { AciString } from '../types/ServiceId';
|
||||||
import type { LoggerType } from '../types/Logging';
|
import type { LoggerType } from '../types/Logging';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { isAciString } from './isAciString';
|
import { isAciString } from './isAciString';
|
||||||
|
import { strictAssert } from './assert';
|
||||||
|
|
||||||
export function normalizeAci(
|
export function normalizeAci(
|
||||||
rawAci: string,
|
rawAci: string,
|
||||||
|
@ -28,6 +29,7 @@ export function normalizeAci(
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = rawAci.toLowerCase();
|
const result = rawAci.toLowerCase();
|
||||||
|
strictAssert(!result.startsWith('pni:'), 'ACI should not start with PNI:');
|
||||||
|
|
||||||
if (!isAciString(result)) {
|
if (!isAciString(result)) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|
Loading…
Reference in a new issue