Roundtrip group.blocked state
This commit is contained in:
parent
edec098d40
commit
65055fd475
4 changed files with 76 additions and 0 deletions
|
@ -188,6 +188,7 @@ message Group {
|
|||
bool hideStory = 3;
|
||||
StorySendMode storySendMode = 4;
|
||||
GroupSnapshot snapshot = 5;
|
||||
bool blocked = 6;
|
||||
|
||||
// These are simply plaintext copies of the groups proto from Groups.proto.
|
||||
// They should be kept completely in-sync with Groups.proto.
|
||||
|
|
|
@ -910,6 +910,9 @@ export class BackupExportStream extends Readable {
|
|||
whitelisted: convo.profileSharing,
|
||||
hideStory: convo.hideStory === true,
|
||||
storySendMode,
|
||||
blocked: convo.groupId
|
||||
? window.storage.blocked.isGroupBlocked(convo.groupId)
|
||||
: false,
|
||||
snapshot: {
|
||||
title: {
|
||||
title: convo.name?.trim() ?? '',
|
||||
|
|
|
@ -1116,6 +1116,9 @@ export class BackupImportStream extends Writable {
|
|||
if (avatarUrl) {
|
||||
this.#pendingGroupAvatars.set(attrs.id, avatarUrl);
|
||||
}
|
||||
if (group.blocked) {
|
||||
await window.storage.blocked.addBlockedGroup(groupId);
|
||||
}
|
||||
|
||||
return attrs;
|
||||
}
|
||||
|
|
69
ts/test-electron/backup/conversations_test.ts
Normal file
69
ts/test-electron/backup/conversations_test.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { getRandomBytes } from '../../Crypto';
|
||||
import * as Bytes from '../../Bytes';
|
||||
import { setupBasics, symmetricRoundtripHarness } from './helpers';
|
||||
import { loadAllAndReinitializeRedux } from '../../services/allLoaders';
|
||||
import { deriveGroupID, deriveGroupSecretParams } from '../../util/zkgroup';
|
||||
import { DataWriter } from '../../sql/Client';
|
||||
|
||||
function getGroupTestInfo() {
|
||||
const masterKey = getRandomBytes(32);
|
||||
const secretParams = deriveGroupSecretParams(masterKey);
|
||||
const groupId = Bytes.toBase64(deriveGroupID(secretParams));
|
||||
|
||||
return { masterKey: Bytes.toBase64(masterKey), secretParams, groupId };
|
||||
}
|
||||
|
||||
describe('backup/conversations', () => {
|
||||
beforeEach(async () => {
|
||||
await DataWriter._removeAllMessages();
|
||||
await DataWriter._removeAllConversations();
|
||||
window.storage.reset();
|
||||
|
||||
await setupBasics();
|
||||
|
||||
await loadAllAndReinitializeRedux();
|
||||
});
|
||||
|
||||
it('roundtrips block state on group conversations', async () => {
|
||||
const blockedGroupInfo = getGroupTestInfo();
|
||||
await window.ConversationController.getOrCreateAndWait(
|
||||
blockedGroupInfo.groupId,
|
||||
'group',
|
||||
{
|
||||
groupId: blockedGroupInfo.groupId,
|
||||
groupVersion: 2,
|
||||
masterKey: blockedGroupInfo.masterKey,
|
||||
name: 'Rock Enthusiasts',
|
||||
}
|
||||
);
|
||||
|
||||
const unblockedGroupInfo = getGroupTestInfo();
|
||||
await window.ConversationController.getOrCreateAndWait(
|
||||
unblockedGroupInfo.groupId,
|
||||
'group',
|
||||
{
|
||||
groupId: unblockedGroupInfo.groupId,
|
||||
groupVersion: 2,
|
||||
masterKey: unblockedGroupInfo.masterKey,
|
||||
name: 'Rock Enthusiasts 2',
|
||||
}
|
||||
);
|
||||
|
||||
await window.storage.blocked.addBlockedGroup(blockedGroupInfo.groupId);
|
||||
|
||||
await symmetricRoundtripHarness([]);
|
||||
|
||||
const blockedGroupAfter = window.ConversationController.get(
|
||||
blockedGroupInfo.groupId
|
||||
);
|
||||
assert.isTrue(blockedGroupAfter?.isBlocked());
|
||||
const unblockedGroupAfter = window.ConversationController.get(
|
||||
unblockedGroupInfo.groupId
|
||||
);
|
||||
assert.isFalse(unblockedGroupAfter?.isBlocked());
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue