Skip to content

Commit

Permalink
Sync MyStories using the ID not the name
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Aug 4, 2022
1 parent 6d1a27b commit 782838c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
6 changes: 2 additions & 4 deletions ts/background.ts
Expand Up @@ -2715,7 +2715,7 @@ export async function startApp(): Promise<void> {

const partialConversation: ValidateConversationType = {
e164: details.number,
uuid: UUID.fromString(details.uuid),
uuid: UUID.cast(details.uuid),
type: 'private',
};

Expand Down Expand Up @@ -3454,9 +3454,7 @@ export async function startApp(): Promise<void> {
serverTimestamp: data.serverTimestamp,
source: data.source,
sourceDevice: data.sourceDevice,
sourceUuid: data.sourceUuid
? UUID.fromString(data.sourceUuid)
: undefined,
sourceUuid: data.sourceUuid ? UUID.cast(data.sourceUuid) : undefined,
timestamp: data.timestamp,
type: data.message.isStory ? 'story' : 'incoming',
unidentifiedDeliveryReceived: data.unidentifiedDeliveryReceived,
Expand Down
4 changes: 1 addition & 3 deletions ts/components/StoriesSettingsModal.tsx
Expand Up @@ -239,9 +239,7 @@ export const StoriesSettingsModal = ({
return undefined;
}

const isSelected = selectedConversationUuids.has(
UUID.fromString(contact.uuid)
);
const isSelected = selectedConversationUuids.has(UUID.cast(contact.uuid));

return {
type: RowType.ContactCheckbox,
Expand Down
16 changes: 10 additions & 6 deletions ts/services/storageRecordOps.ts
Expand Up @@ -44,13 +44,15 @@ import * as preferredReactionEmoji from '../reactions/preferredReactionEmoji';
import { SignalService as Proto } from '../protobuf';
import * as log from '../logging/log';
import type { UUIDStringType } from '../types/UUID';
import { MY_STORIES_ID } from '../types/Stories';
import * as Stickers from '../types/Stickers';
import type {
StoryDistributionWithMembersType,
StickerPackInfoType,
} from '../sql/Interface';
import dataInterface from '../sql/Client';
import { MY_STORIES_ID } from '../types/Stories';

const MY_STORIES_BYTES = uuidToBytes(MY_STORIES_ID);

type RecordClass =
| Proto.IAccountRecord
Expand Down Expand Up @@ -1265,10 +1267,12 @@ export async function mergeStoryDistributionListRecord(

const details: Array<string> = [];

const listId =
storyDistributionListRecord.name === MY_STORIES_ID
? MY_STORIES_ID
: bytesToUuid(storyDistributionListRecord.identifier);
const listId = Bytes.areEqual(
MY_STORIES_BYTES,
storyDistributionListRecord.identifier
)
? MY_STORIES_ID
: bytesToUuid(storyDistributionListRecord.identifier);

if (!listId) {
throw new Error('Could not parse distribution list id');
Expand All @@ -1279,7 +1283,7 @@ export async function mergeStoryDistributionListRecord(

const remoteListMembers: Array<UUIDStringType> = (
storyDistributionListRecord.recipientUuids || []
).map(UUID.fromString);
).map(UUID.cast);

if (storyDistributionListRecord.__unknownFields) {
details.push('adding unknown fields');
Expand Down
4 changes: 0 additions & 4 deletions ts/types/UUID.ts
Expand Up @@ -77,8 +77,4 @@ export class UUID {
}
return new UUID(`${padded}-0000-4000-8000-${'0'.repeat(12)}`);
}

public static fromString(value: string): UUIDStringType {
return new UUID(value).toString();
}
}
2 changes: 1 addition & 1 deletion ts/util/sendStoryMessage.ts
Expand Up @@ -84,7 +84,7 @@ export async function sendStoryMessage(
return acc;
}

const uuid = UUID.fromString(id);
const uuid = UUID.cast(id);
if (inBlockList.has(uuid)) {
return acc;
}
Expand Down

0 comments on commit 782838c

Please sign in to comment.