Skip to content

Commit 4c6c690

Browse files
authored
feat: support encrypted seen-video syncing (#12)
Add the optional seen_videos capability and a separate seenVideos collection without changing existing sync data formats. Related to OpenTubeX/OpenTubeX#1208.
1 parent 94f41df commit 4c6c690

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/dto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct SyncCapabilities {
3131
pub history_page_size: u32,
3232
pub key_pairing: u8,
3333
pub account_sessions: u8,
34+
pub seen_videos: u8,
3435
}
3536

3637
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]

src/handlers/encrypted_sync.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub(crate) fn sync_capabilities() -> SyncCapabilities {
6565
history_page_size: MAX_PAGE_SIZE,
6666
key_pairing: 1,
6767
account_sessions: 1,
68+
seen_videos: 1,
6869
}
6970
}
7071

@@ -74,7 +75,7 @@ fn collection_limit(collection: &str) -> HandlerResult<usize> {
7475
// Deprecated compatibility collection. Saved channel preferences now
7576
// belong in `settings`; keep accepting this while old clients remain.
7677
"sessions" | "sessionsV2" | "profiles" | "playbackSpeeds" => Ok(8 * MEBIBYTE),
77-
"subscriptions" | "playlistBookmarks" => Ok(16 * MEBIBYTE),
78+
"subscriptions" | "playlistBookmarks" | "seenVideos" => Ok(16 * MEBIBYTE),
7879
"playlists" | "history" => Ok(MAX_ENCRYPTED_SYNC_BYTES),
7980
_ => Err(HandlerError::ValidationErrorWithContext(
8081
"unknown encrypted sync collection".to_owned(),
@@ -232,6 +233,8 @@ mod tests {
232233
assert_eq!(collection_limit("sessionsV2").unwrap(), 8 * MEBIBYTE);
233234
assert_eq!(collection_limit("subscriptions").unwrap(), 16 * MEBIBYTE);
234235
assert_eq!(collection_limit("history").unwrap(), 64 * MEBIBYTE);
236+
assert_eq!(collection_limit("seenVideos").unwrap(), 16 * MEBIBYTE);
237+
assert_eq!(super::sync_capabilities().seen_videos, 1);
235238
assert!(collection_limit("unknown").is_err());
236239
}
237240
}

0 commit comments

Comments
 (0)