Fix crash when changing your username
This commit is contained in:
parent
48836d5761
commit
393b740fe6
2 changed files with 22 additions and 6 deletions
|
@ -1753,7 +1753,10 @@ export class ConversationModel extends window.Backbone
|
||||||
id: this.id,
|
id: this.id,
|
||||||
uuid: this.get('uuid'),
|
uuid: this.get('uuid'),
|
||||||
e164: this.get('e164'),
|
e164: this.get('e164'),
|
||||||
username: this.get('username'),
|
|
||||||
|
// We had previously stored `null` instead of `undefined` in some cases. We should
|
||||||
|
// be able to remove this `dropNull` once usernames have gone to production.
|
||||||
|
username: dropNull(this.get('username')),
|
||||||
|
|
||||||
about: this.getAboutText(),
|
about: this.getAboutText(),
|
||||||
aboutText: this.get('about'),
|
aboutText: this.get('about'),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020-2021 Signal Messenger, LLC
|
// Copyright 2020-2022 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
|
@ -38,7 +38,7 @@ import type { SocketStatus } from '../types/SocketStatus';
|
||||||
import { toLogFormat } from '../types/errors';
|
import { toLogFormat } from '../types/errors';
|
||||||
import { isPackIdValid, redactPackId } from '../types/Stickers';
|
import { isPackIdValid, redactPackId } from '../types/Stickers';
|
||||||
import type { UUID, UUIDStringType } from '../types/UUID';
|
import type { UUID, UUIDStringType } from '../types/UUID';
|
||||||
import { UUIDKind } from '../types/UUID';
|
import { isValidUuid, UUIDKind } from '../types/UUID';
|
||||||
import * as Bytes from '../Bytes';
|
import * as Bytes from '../Bytes';
|
||||||
import {
|
import {
|
||||||
constantTimeEqual,
|
constantTimeEqual,
|
||||||
|
@ -1265,12 +1265,25 @@ export function initialize({
|
||||||
return `identity=${value}`;
|
return `identity=${value}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function whoami() {
|
async function whoami(): Promise<WhoamiResultType> {
|
||||||
return (await _ajax({
|
const response = await _ajax({
|
||||||
call: 'whoami',
|
call: 'whoami',
|
||||||
httpType: 'GET',
|
httpType: 'GET',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
})) as WhoamiResultType;
|
});
|
||||||
|
|
||||||
|
if (!isRecord(response)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
uuid: isValidUuid(response.uuid) ? response.uuid : undefined,
|
||||||
|
pni: isValidUuid(response.pni) ? response.pni : undefined,
|
||||||
|
number:
|
||||||
|
typeof response.number === 'string' ? response.number : undefined,
|
||||||
|
username:
|
||||||
|
typeof response.username === 'string' ? response.username : undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendChallengeResponse(challengeResponse: ChallengeType) {
|
async function sendChallengeResponse(challengeResponse: ChallengeType) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue