Migrate schema to service ids

This commit is contained in:
Fedor Indutny 2023-08-16 22:54:39 +02:00 committed by Jamie Kyle
parent 71958f8a01
commit 8b0da36caa
258 changed files with 4795 additions and 2613 deletions

View file

@ -42,32 +42,34 @@ export class Blocked {
await this.storage.put(BLOCKED_NUMBERS_ID, without(numbers, number));
}
public getBlockedUuids(): Array<ServiceIdString> {
public getBlockedServiceIds(): Array<ServiceIdString> {
return this.storage.get(BLOCKED_UUIDS_ID, new Array<ServiceIdString>());
}
public isUuidBlocked(uuid: ServiceIdString): boolean {
return this.getBlockedUuids().includes(uuid);
public isServiceIdBlocked(serviceId: ServiceIdString): boolean {
return this.getBlockedServiceIds().includes(serviceId);
}
public async addBlockedUuid(uuid: ServiceIdString): Promise<void> {
const uuids = this.getBlockedUuids();
if (uuids.includes(uuid)) {
public async addBlockedServiceId(serviceId: ServiceIdString): Promise<void> {
const serviceIds = this.getBlockedServiceIds();
if (serviceIds.includes(serviceId)) {
return;
}
log.info('adding', uuid, 'to blocked list');
await this.storage.put(BLOCKED_UUIDS_ID, uuids.concat(uuid));
log.info('adding', serviceId, 'to blocked list');
await this.storage.put(BLOCKED_UUIDS_ID, serviceIds.concat(serviceId));
}
public async removeBlockedUuid(uuid: ServiceIdString): Promise<void> {
const numbers = this.getBlockedUuids();
if (!numbers.includes(uuid)) {
public async removeBlockedServiceId(
serviceId: ServiceIdString
): Promise<void> {
const numbers = this.getBlockedServiceIds();
if (!numbers.includes(serviceId)) {
return;
}
log.info('removing', uuid, 'from blocked list');
await this.storage.put(BLOCKED_UUIDS_ID, without(numbers, uuid));
log.info('removing', serviceId, 'from blocked list');
await this.storage.put(BLOCKED_UUIDS_ID, without(numbers, serviceId));
}
public getBlockedGroups(): Array<string> {

View file

@ -27,7 +27,7 @@ export type SetCredentialsOptions = {
export class User {
constructor(private readonly storage: StorageInterface) {}
public async setUuidAndDeviceId(
public async setAciAndDeviceId(
aci: AciString,
deviceId: number
): Promise<void> {