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 { restoreRemoteConfigFromStorage } from './RemoteConfig';
|
||||||
import { getParametersForRedux, loadAll } from './services/allLoaders';
|
import { getParametersForRedux, loadAll } from './services/allLoaders';
|
||||||
import { checkFirstEnvelope } from './util/checkFirstEnvelope';
|
import { checkFirstEnvelope } from './util/checkFirstEnvelope';
|
||||||
|
import { BLOCKED_UUIDS_ID } from './textsecure/storage/Blocked';
|
||||||
|
|
||||||
export function isOverHourIntoPast(timestamp: number): boolean {
|
export function isOverHourIntoPast(timestamp: number): boolean {
|
||||||
return isNumber(timestamp) && isOlderThan(timestamp, HOUR);
|
return isNumber(timestamp) && isOlderThan(timestamp, HOUR);
|
||||||
|
@ -1360,6 +1361,18 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
initializeExpiringMessageService(singleProtoJobQueue);
|
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...');
|
log.info('Expiration start timestamp cleanup: starting...');
|
||||||
const messagesUnexpectedlyMissingExpirationStartTimestamp =
|
const messagesUnexpectedlyMissingExpirationStartTimestamp =
|
||||||
await DataReader.getMessagesUnexpectedlyMissingExpirationStartTimestamp();
|
await DataReader.getMessagesUnexpectedlyMissingExpirationStartTimestamp();
|
||||||
|
|
|
@ -930,7 +930,7 @@ export class ConversationModel extends window.Backbone
|
||||||
const wasBlocked = this.isBlocked();
|
const wasBlocked = this.isBlocked();
|
||||||
|
|
||||||
const serviceId = this.getServiceId();
|
const serviceId = this.getServiceId();
|
||||||
if (serviceId) {
|
if (serviceId && isAciString(serviceId)) {
|
||||||
drop(window.storage.blocked.addBlockedServiceId(serviceId));
|
drop(window.storage.blocked.addBlockedServiceId(serviceId));
|
||||||
blocked = true;
|
blocked = true;
|
||||||
}
|
}
|
||||||
|
@ -962,7 +962,7 @@ export class ConversationModel extends window.Backbone
|
||||||
const wasBlocked = this.isBlocked();
|
const wasBlocked = this.isBlocked();
|
||||||
|
|
||||||
const serviceId = this.getServiceId();
|
const serviceId = this.getServiceId();
|
||||||
if (serviceId) {
|
if (serviceId && isAciString(serviceId)) {
|
||||||
drop(window.storage.blocked.removeBlockedServiceId(serviceId));
|
drop(window.storage.blocked.removeBlockedServiceId(serviceId));
|
||||||
unblocked = true;
|
unblocked = true;
|
||||||
}
|
}
|
||||||
|
@ -2344,6 +2344,10 @@ export class ConversationModel extends window.Backbone
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
});
|
});
|
||||||
|
if (!this.get('active_at')) {
|
||||||
|
this.set({ active_at: Date.now() });
|
||||||
|
await DataWriter.updateConversation(this.attributes);
|
||||||
|
}
|
||||||
window.MessageCache.toMessageAttributes(message);
|
window.MessageCache.toMessageAttributes(message);
|
||||||
this.trigger('newmessage', message);
|
this.trigger('newmessage', message);
|
||||||
drop(this.updateLastMessage());
|
drop(this.updateLastMessage());
|
||||||
|
|
|
@ -7,9 +7,9 @@ import type { StorageInterface } from '../../types/Storage.d';
|
||||||
import type { ServiceIdString } from '../../types/ServiceId';
|
import type { ServiceIdString } from '../../types/ServiceId';
|
||||||
import * as log from '../../logging/log';
|
import * as log from '../../logging/log';
|
||||||
|
|
||||||
const BLOCKED_NUMBERS_ID = 'blocked';
|
export const BLOCKED_NUMBERS_ID = 'blocked';
|
||||||
const BLOCKED_UUIDS_ID = 'blocked-uuids';
|
export const BLOCKED_UUIDS_ID = 'blocked-uuids';
|
||||||
const BLOCKED_GROUPS_ID = 'blocked-groups';
|
export const BLOCKED_GROUPS_ID = 'blocked-groups';
|
||||||
|
|
||||||
export class Blocked {
|
export class Blocked {
|
||||||
constructor(private readonly storage: StorageInterface) {}
|
constructor(private readonly storage: StorageInterface) {}
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import type { ConversationAttributesType } from '../model-types';
|
import type { ConversationAttributesType } from '../model-types';
|
||||||
|
import { isAciString } from './isAciString';
|
||||||
|
|
||||||
export function isBlocked(
|
export function isBlocked(
|
||||||
attributes: Pick<ConversationAttributesType, 'e164' | 'groupId' | 'serviceId'>
|
attributes: Pick<ConversationAttributesType, 'e164' | 'groupId' | 'serviceId'>
|
||||||
): boolean {
|
): boolean {
|
||||||
const { e164, groupId, serviceId } = attributes;
|
const { e164, groupId, serviceId } = attributes;
|
||||||
if (serviceId) {
|
if (isAciString(serviceId)) {
|
||||||
return window.storage.blocked.isServiceIdBlocked(serviceId);
|
return window.storage.blocked.isServiceIdBlocked(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue