Preliminary support for destinationUuid field

This commit is contained in:
Fedor Indutny 2021-11-12 22:26:52 +01:00 committed by GitHub
parent bb15cfc622
commit 066a23a6a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 154 additions and 36 deletions

View file

@ -5,7 +5,7 @@ import type { WebAPICredentials } from '../Types.d';
import { strictAssert } from '../../util/assert';
import type { StorageInterface } from '../../types/Storage.d';
import { UUID } from '../../types/UUID';
import { UUID, UUIDKind } from '../../types/UUID';
import * as log from '../../logging/log';
import Helpers from '../Helpers';
@ -70,6 +70,27 @@ export class User {
return uuid;
}
public getPni(): UUID | undefined {
const pni = this.storage.get('pni');
if (pni === undefined) return undefined;
return new UUID(pni);
}
public getOurUuidKind(uuid: UUID): UUIDKind {
const ourUuid = this.getUuid();
if (ourUuid?.toString() === uuid.toString()) {
return UUIDKind.ACI;
}
const pni = this.getPni();
if (pni?.toString() === uuid.toString()) {
return UUIDKind.PNI;
}
return UUIDKind.Unknown;
}
public getDeviceId(): number | undefined {
const value = this._getDeviceIdFromUuid() || this._getDeviceIdFromNumber();
if (value === undefined) {