Ensure that non-ACIs are excluded from the blocked UUIDs list
This commit is contained in:
parent
42cc5e0013
commit
adcf2212e5
4 changed files with 24 additions and 6 deletions
|
@ -197,6 +197,7 @@ import { DataReader, DataWriter } from './sql/Client';
|
|||
import { restoreRemoteConfigFromStorage } from './RemoteConfig';
|
||||
import { getParametersForRedux, loadAll } from './services/allLoaders';
|
||||
import { checkFirstEnvelope } from './util/checkFirstEnvelope';
|
||||
import { BLOCKED_UUIDS_ID } from './textsecure/storage/Blocked';
|
||||
|
||||
export function isOverHourIntoPast(timestamp: number): boolean {
|
||||
return isNumber(timestamp) && isOlderThan(timestamp, HOUR);
|
||||
|
@ -1360,6 +1361,18 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
initializeExpiringMessageService(singleProtoJobQueue);
|
||||
|
||||
log.info('Blocked uuids cleanup: starting...');
|
||||
const blockedUuids = window.storage.get(BLOCKED_UUIDS_ID, []);
|
||||
const blockedAcis = blockedUuids.filter(isAciString);
|
||||
const diff = blockedUuids.length - blockedAcis.length;
|
||||
if (diff > 0) {
|
||||
log.warn(
|
||||
`Blocked uuids cleanup: Found ${diff} non-ACIs in blocked list. Removing.`
|
||||
);
|
||||
await window.storage.put(BLOCKED_UUIDS_ID, blockedAcis);
|
||||
}
|
||||
log.info('Blocked uuids cleanup: complete');
|
||||
|
||||
log.info('Expiration start timestamp cleanup: starting...');
|
||||
const messagesUnexpectedlyMissingExpirationStartTimestamp =
|
||||
await DataReader.getMessagesUnexpectedlyMissingExpirationStartTimestamp();
|
||||
|
|
|
@ -930,7 +930,7 @@ export class ConversationModel extends window.Backbone
|
|||
const wasBlocked = this.isBlocked();
|
||||
|
||||
const serviceId = this.getServiceId();
|
||||
if (serviceId) {
|
||||
if (serviceId && isAciString(serviceId)) {
|
||||
drop(window.storage.blocked.addBlockedServiceId(serviceId));
|
||||
blocked = true;
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ export class ConversationModel extends window.Backbone
|
|||
const wasBlocked = this.isBlocked();
|
||||
|
||||
const serviceId = this.getServiceId();
|
||||
if (serviceId) {
|
||||
if (serviceId && isAciString(serviceId)) {
|
||||
drop(window.storage.blocked.removeBlockedServiceId(serviceId));
|
||||
unblocked = true;
|
||||
}
|
||||
|
@ -2344,6 +2344,10 @@ export class ConversationModel extends window.Backbone
|
|||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
||||
forceSave: true,
|
||||
});
|
||||
if (!this.get('active_at')) {
|
||||
this.set({ active_at: Date.now() });
|
||||
await DataWriter.updateConversation(this.attributes);
|
||||
}
|
||||
window.MessageCache.toMessageAttributes(message);
|
||||
this.trigger('newmessage', message);
|
||||
drop(this.updateLastMessage());
|
||||
|
|
|
@ -7,9 +7,9 @@ import type { StorageInterface } from '../../types/Storage.d';
|
|||
import type { ServiceIdString } from '../../types/ServiceId';
|
||||
import * as log from '../../logging/log';
|
||||
|
||||
const BLOCKED_NUMBERS_ID = 'blocked';
|
||||
const BLOCKED_UUIDS_ID = 'blocked-uuids';
|
||||
const BLOCKED_GROUPS_ID = 'blocked-groups';
|
||||
export const BLOCKED_NUMBERS_ID = 'blocked';
|
||||
export const BLOCKED_UUIDS_ID = 'blocked-uuids';
|
||||
export const BLOCKED_GROUPS_ID = 'blocked-groups';
|
||||
|
||||
export class Blocked {
|
||||
constructor(private readonly storage: StorageInterface) {}
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ConversationAttributesType } from '../model-types';
|
||||
import { isAciString } from './isAciString';
|
||||
|
||||
export function isBlocked(
|
||||
attributes: Pick<ConversationAttributesType, 'e164' | 'groupId' | 'serviceId'>
|
||||
): boolean {
|
||||
const { e164, groupId, serviceId } = attributes;
|
||||
if (serviceId) {
|
||||
if (isAciString(serviceId)) {
|
||||
return window.storage.blocked.isServiceIdBlocked(serviceId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue