mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 00:07:56 +01:00
Improve username validity checks
This commit is contained in:
@@ -267,6 +267,7 @@ import { maybeNotify } from '../messages/maybeNotify.preload.js';
|
||||
import { missingCaseError } from '../util/missingCaseError.std.js';
|
||||
import * as Message from '../types/Message2.preload.js';
|
||||
import { itemStorage } from '../textsecure/Storage.preload.js';
|
||||
import { isUsernameValid } from '../util/Username.dom.js';
|
||||
|
||||
const { compact, isNumber, throttle, debounce } = lodash;
|
||||
|
||||
@@ -4454,6 +4455,16 @@ export class ConversationModel {
|
||||
return;
|
||||
}
|
||||
|
||||
if (username && !isUsernameValid(username)) {
|
||||
log.error(
|
||||
`updateUsername(${this.idForLogging()}): username is invalid, dropping`,
|
||||
{
|
||||
fromStorageService,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info(`updateUsername(${this.idForLogging()}): updating username`);
|
||||
|
||||
this.#doSet({ username });
|
||||
|
||||
@@ -1259,7 +1259,7 @@ export class BackupExportStream extends Readable {
|
||||
aci,
|
||||
pni,
|
||||
e164,
|
||||
username: convo.username ?? null,
|
||||
username: convo.username || null,
|
||||
blocked: convo.serviceId
|
||||
? itemStorage.blocked.isServiceIdBlocked(convo.serviceId)
|
||||
: null,
|
||||
|
||||
@@ -1378,7 +1378,7 @@ export async function mergeContactRecord(
|
||||
};
|
||||
}
|
||||
|
||||
await conversation.updateUsername(dropNull(contactRecord.username), {
|
||||
await conversation.updateUsername(dropNull(contactRecord.username || null), {
|
||||
shouldSave: false,
|
||||
fromStorageService: true,
|
||||
});
|
||||
@@ -1986,7 +1986,7 @@ export async function mergeAccountRecord(
|
||||
needsStorageServiceSync: false,
|
||||
});
|
||||
|
||||
await conversation.updateUsername(dropNull(username), {
|
||||
await conversation.updateUsername(dropNull(username || null), {
|
||||
shouldSave: false,
|
||||
fromStorageService: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user