MCPcopy
hub / github.com/signalapp/Signal-Desktop / initStorage

Function initStorage

ts/test-mock/storage/fixtures.node.ts:52–158  ·  view source on GitHub ↗
(
  options?: BootstrapOptions
)

Source from the content-addressed store, hash-verified

50// group, and one for the first contact (so that both will appear in the left
51// pane).
52export async function initStorage(
53 options?: BootstrapOptions
54): Promise<InitStorageResultType> {
55 // Creates primary device, contacts
56 const bootstrap = new Bootstrap(options);
57
58 await bootstrap.init();
59
60 try {
61 // Populate storage service
62 const { contacts, phone } = bootstrap;
63
64 const [firstContact] = contacts as [PrimaryDevice];
65
66 const members = [...contacts].slice(0, GROUP_SIZE);
67
68 const group = await phone.createGroup({
69 title: 'Mock Group',
70 members: [phone, ...members],
71 });
72
73 let state = StorageState.getEmpty();
74
75 state = state.updateAccount({
76 profileKey: phone.profileKey.serialize(),
77 givenName: phone.profileName,
78 });
79
80 state = state
81 .addGroup(group, {
82 whitelisted: true,
83 })
84 .pinGroup(group);
85
86 for (const contact of contacts) {
87 state = state.addContact(contact, {
88 identityState: Proto.ContactRecord.IdentityState.VERIFIED,
89 whitelisted: true,
90
91 identityKey: contact.publicKey.serialize(),
92 profileKey: contact.profileKey.serialize(),
93 givenName: contact.profileName,
94 });
95 }
96
97 state = state.pin(firstContact);
98
99 state = state.addRecord({
100 type: IdentifierType.STORY_DISTRIBUTION_LIST,
101 record: {
102 storyDistributionList: {
103 allowsReplies: true,
104 identifier: uuidToBytes(MY_STORY_ID),
105 isBlockList: true,
106 name: MY_STORY_ID,
107 deletedAtTimestamp: null,
108 recipientServiceIdsBinary: null,
109 },

Calls 6

initMethod · 0.95
linkMethod · 0.95
getTimestampMethod · 0.95
saveLogsMethod · 0.95
uuidToBytesFunction · 0.90
pinMethod · 0.80

Tested by

no test coverage detected