Add unsupported/sse message export/import

This commit is contained in:
Fedor Indutny 2024-05-29 10:19:33 -07:00 committed by GitHub
parent c67a346218
commit 481928fa4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 396 additions and 116 deletions

View file

@ -7,6 +7,7 @@ import Data from '../../sql/Client';
import { SignalService as Proto } from '../../protobuf';
import { generateAci, generatePni } from '../../types/ServiceId';
import type { ServiceIdString } from '../../types/ServiceId';
import type { MessageAttributesType } from '../../model-types';
import type { GroupV2ChangeType } from '../../groups';
import { getRandomBytes } from '../../Crypto';
@ -42,7 +43,13 @@ let counter = 0;
function createMessage(
change: GroupV2ChangeType,
{ disableIncrement }: { disableIncrement: boolean } = {
{
disableIncrement = false,
sourceServiceId = change.from || OUR_ACI,
}: {
disableIncrement?: boolean;
sourceServiceId?: ServiceIdString;
} = {
disableIncrement: false,
}
): MessageAttributesType {
@ -60,6 +67,7 @@ function createMessage(
sent_at: counter,
timestamp: counter,
type: 'group-v2-change',
sourceServiceId,
};
}
@ -695,16 +703,19 @@ describe('backup/groupv2/notifications', () => {
});
it('MemberAddFromInvited items', async () => {
const firstBefore = createMessage({
from: OUR_PNI,
details: [
{
type: 'member-add-from-invite',
aci: OUR_ACI,
inviter: CONTACT_B,
},
],
});
const firstBefore = createMessage(
{
from: OUR_PNI,
details: [
{
type: 'member-add-from-invite',
aci: OUR_ACI,
inviter: CONTACT_B,
},
],
},
{ sourceServiceId: OUR_ACI }
);
const firstAfter = createMessage(
{
from: OUR_ACI,
@ -719,15 +730,18 @@ describe('backup/groupv2/notifications', () => {
{ disableIncrement: true }
);
const secondBefore = createMessage({
from: OUR_PNI,
details: [
{
type: 'member-add-from-invite',
aci: OUR_ACI,
},
],
});
const secondBefore = createMessage(
{
from: OUR_PNI,
details: [
{
type: 'member-add-from-invite',
aci: OUR_ACI,
},
],
},
{ sourceServiceId: OUR_ACI }
);
const secondAfter = createMessage(
{
from: OUR_ACI,
@ -741,15 +755,18 @@ describe('backup/groupv2/notifications', () => {
{ disableIncrement: true }
);
const thirdBefore = createMessage({
from: CONTACT_A_PNI,
details: [
{
type: 'member-add-from-invite',
aci: CONTACT_A,
},
],
});
const thirdBefore = createMessage(
{
from: CONTACT_A_PNI,
details: [
{
type: 'member-add-from-invite',
aci: CONTACT_A,
},
],
},
{ sourceServiceId: CONTACT_A }
);
const thirdAfter = createMessage(
{
from: CONTACT_A,
@ -763,16 +780,19 @@ describe('backup/groupv2/notifications', () => {
{ disableIncrement: true }
);
const fourthBefore = createMessage({
from: CONTACT_A_PNI,
details: [
{
type: 'member-add-from-invite',
aci: CONTACT_A,
pni: CONTACT_A_PNI,
},
],
});
const fourthBefore = createMessage(
{
from: CONTACT_A_PNI,
details: [
{
type: 'member-add-from-invite',
aci: CONTACT_A,
pni: CONTACT_A_PNI,
},
],
},
{ sourceServiceId: CONTACT_A }
);
const fourthAfter = createMessage(
{
from: CONTACT_A,
@ -829,14 +849,17 @@ describe('backup/groupv2/notifications', () => {
it('MemberAddFromLink items asymmetric', async () => {
const before: Array<MessageAttributesType> = [
createMessage({
details: [
{
type: 'member-add-from-link',
aci: CONTACT_A,
},
],
}),
createMessage(
{
details: [
{
type: 'member-add-from-link',
aci: CONTACT_A,
},
],
},
{ sourceServiceId: CONTACT_A }
),
];
const after: Array<MessageAttributesType> = [
createMessage(
@ -2008,6 +2031,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: CONTACT_A,
};
counter += 1;
@ -2023,6 +2047,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: CONTACT_A,
};
const messages: Array<MessageAttributesType> = [
@ -2099,6 +2124,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
counter += 1;
@ -2114,6 +2140,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
counter += 1;
@ -2129,6 +2156,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
const messages: Array<MessageAttributesType> = [
@ -2160,6 +2188,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
const legacyAfter = {
id: generateGuid(),
@ -2173,6 +2202,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
counter += 1;
@ -2191,6 +2221,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
const allDataAfter = {
id: generateGuid(),
@ -2204,6 +2235,7 @@ describe('backup/groupv2/notifications', () => {
received_at: counter,
sent_at: counter,
timestamp: counter,
sourceServiceId: OUR_ACI,
};
const before = [legacyBefore, allDataBefore];