Skip to content

Commit ad59d90

Browse files
Update backup validator with LocatorInfo
1 parent 99c0c9d commit ad59d90

13 files changed

+302
-313
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
v0.73.1
22

3+
- Backups: the now-deprecated remote content locator fields are ignored and the new FilePointer.locator_info field must
4+
be set.

rust/message-backup/src/backup/account_data.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub struct AccountSettings<M: Method + ReferencedTypes> {
123123
pub preferred_reaction_emoji: M::Value<Vec<String>>,
124124
pub default_chat_style: M::Value<Option<ChatStyle<M>>>,
125125
pub custom_chat_colors: CustomColorMap<M>,
126+
pub optimize_on_device_storage: M::Value<bool>,
126127
}
127128

128129
#[derive(Copy, Clone, Debug, PartialEq, serde::Serialize)]
@@ -361,6 +362,7 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp>
361362
preferredReactionEmoji,
362363
defaultChatStyle,
363364
customChatColors,
365+
optimizeOnDeviceStorage,
364366
special_fields: _,
365367
} = value;
366368

@@ -403,6 +405,7 @@ impl<M: Method + ReferencedTypes, C: ReportUnusualTimestamp>
403405
has_completed_username_onboarding: M::value(hasCompletedUsernameOnboarding),
404406
preferred_reaction_emoji: M::value(preferredReactionEmoji),
405407
universal_expire_timer: M::value(universal_expire_timer),
408+
optimize_on_device_storage: M::value(optimizeOnDeviceStorage),
406409
})
407410
}
408411
}
@@ -460,6 +463,7 @@ mod test {
460463
special_fields: Default::default(),
461464
})
462465
.into(),
466+
optimizeOnDeviceStorage: true,
463467
..Default::default()
464468
}
465469
}
@@ -536,6 +540,7 @@ mod test {
536540
universal_expire_timer: None,
537541
preferred_reaction_emoji: vec![],
538542
custom_chat_colors: CustomColorMap::from_proto_test_data(),
543+
optimize_on_device_storage: true,
539544
},
540545
avatar_url_path: "".to_string(),
541546
backup_subscription: Some(IapSubscriberData {

rust/message-backup/src/backup/chat/chat_style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ mod test {
583583
#[test_case(|x| x.set_wallpaperPhoto(proto::FilePointer::test_data()) => Ok(()); "wallpaper photo")]
584584
#[test_case(
585585
|x| x.set_wallpaperPhoto(proto::FilePointer::default()) =>
586-
Err(ChatStyleError::WallpaperPhoto(FilePointerError::NoLocator));
586+
Err(ChatStyleError::WallpaperPhoto(FilePointerError::NoLocatorInfo));
587587
"invalid wallpaper photo"
588588
)]
589589
#[test_case(

rust/message-backup/src/backup/chat/contact_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ mod test {
264264
#[test_case(
265265
|x| x.contact.as_mut().unwrap().avatar = Some(proto::FilePointer::default()).into() =>
266266
Err(ChatItemError::ContactAttachment(ContactAttachmentError::Avatar(
267-
FilePointerError::NoLocator
267+
FilePointerError::NoLocatorInfo
268268
)));
269269
"with invalid avatar"
270270
)]

rust/message-backup/src/backup/chat/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod test {
9292
#[test_case(|x| x.title = None => Ok(()); "no title")]
9393
#[test_case(|x| x.title = Some("".into()) => Ok(()); "empty title")]
9494
#[test_case(|x| x.image = None.into() => Ok(()); "no image")]
95-
#[test_case(|x| x.image = Some(proto::FilePointer::default()).into() => Err(LinkPreviewError::Image(FilePointerError::NoLocator)); "invalid image")]
95+
#[test_case(|x| x.image = Some(proto::FilePointer::default()).into() => Err(LinkPreviewError::Image(FilePointerError::NoLocatorInfo)); "invalid image")]
9696
#[test_case(|x| x.description = None => Ok(()); "no description")]
9797
#[test_case(|x| x.description = Some("".into()) => Ok(()); "empty description")]
9898
#[test_case(

rust/message-backup/src/backup/chat/story_reply.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ mod test {
157157
"invalid text"
158158
)]
159159
#[test_case(|x| x.mut_textReply().longText = Some(proto::FilePointer::test_data()).into() => Ok(()); "long text")]
160-
#[test_case(|x| x.mut_textReply().longText = Some(Default::default()).into() => Err(DirectStoryReplyError::LongText(FilePointerError::NoLocator)); "invalid long text")]
160+
#[test_case(|x| x.mut_textReply().longText = Some(Default::default()).into() => Err(DirectStoryReplyError::LongText(FilePointerError::NoLocatorInfo)); "invalid long text")]
161161
#[test_case(|x| *x.mut_emoji() = "".into() => Err(DirectStoryReplyError::EmptyEmoji); "empty emoji")]
162162
#[test_case(|x| *x.mut_emoji() = "x".into() => Ok(()); "valid emoji")]
163163
#[test_case(|x| x.reactions.clear() => Ok(()); "no reactions")]

rust/message-backup/src/backup/expected_serialized_backup.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"color": 4279383126
5353
}
5454
}
55-
}
55+
},
56+
"optimize_on_device_storage": true
5657
},
5758
"avatar_url_path": "",
5859
"donation_subscription": null,

0 commit comments

Comments
 (0)