-
Notifications
You must be signed in to change notification settings - Fork 419
refactor(send_queue): generalize SentRequestKey::Media and DependentQueuedRequestKind::UploadFileWithThumbnail to prepare for MSC4274 gallery uploads #4897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
ad72a6d
c97f8f8
88d7f18
fb61003
8888ee8
2ab77d4
4a9ef07
de711e8
3206a05
8bbee70
e2511d9
7bb3335
ee947c6
cc5f655
4202377
4272eae
4ac07d5
9257a0c
773d928
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,12 @@ pub enum QueuedRequestKind { | |
|
|
||
| /// To which media event transaction does this upload relate? | ||
| related_to: OwnedTransactionId, | ||
|
|
||
| /// Accumulated list of infos for previously uploaded files and | ||
| /// thumbnails if used during a gallery transaction. Otherwise empty. | ||
| #[cfg(feature = "unstable-msc4274")] | ||
| #[serde(default)] | ||
| accumulated: Vec<AccumulatedSentMediaInfo>, | ||
| }, | ||
| } | ||
|
|
||
|
|
@@ -219,17 +225,23 @@ pub enum DependentQueuedRequestKind { | |
| key: String, | ||
| }, | ||
|
|
||
| /// Upload a file that had a thumbnail. | ||
| UploadFileWithThumbnail { | ||
| /// Content type for the file itself (not the thumbnail). | ||
| /// Upload a file or thumbnail depending on another file or thumbnail | ||
| /// upload. | ||
| #[serde(rename = "UploadFileWithThumbnail")] | ||
|
Johennes marked this conversation as resolved.
Outdated
|
||
| UploadFileOrThumbnail { | ||
|
Johennes marked this conversation as resolved.
|
||
| /// Content type for the file or thumbnail. | ||
| content_type: String, | ||
|
|
||
| /// Media request necessary to retrieve the file itself (not the | ||
| /// thumbnail). | ||
| /// Media request necessary to retrieve the file or thumbnail itself. | ||
| cache_key: MediaRequestParameters, | ||
|
|
||
| /// To which media transaction id does this upload relate to? | ||
| related_to: OwnedTransactionId, | ||
|
|
||
| /// Whether the depended upon request was a thumbnail or a file upload. | ||
| #[cfg(feature = "unstable-msc4274")] | ||
| #[serde(default = "default_parent_is_thumbnail_upload")] | ||
| parent_is_thumbnail_upload: bool, | ||
| }, | ||
|
|
||
| /// Finish an upload by updating references to the media cache and sending | ||
|
|
@@ -248,6 +260,13 @@ pub enum DependentQueuedRequestKind { | |
| }, | ||
| } | ||
|
|
||
| /// If parent_is_thumbnail_upload is missing, we assume the request is for a | ||
| /// file upload following a thumbnail upload. | ||
|
Johennes marked this conversation as resolved.
Outdated
|
||
| #[cfg(feature = "unstable-msc4274")] | ||
| fn default_parent_is_thumbnail_upload() -> bool { | ||
| true | ||
| } | ||
|
|
||
| /// Detailed record about a thumbnail used when finishing a media upload. | ||
| #[derive(Clone, Debug, Serialize, Deserialize)] | ||
| pub struct FinishUploadThumbnailInfo { | ||
|
|
@@ -310,7 +329,7 @@ impl From<OwnedTransactionId> for ChildTransactionId { | |
| } | ||
| } | ||
|
|
||
| /// Information about a media (and its thumbnail) that have been sent to an | ||
| /// Information about a media (and its thumbnail) that have been sent to a | ||
| /// homeserver. | ||
| #[derive(Clone, Debug, Serialize, Deserialize)] | ||
| pub struct SentMediaInfo { | ||
|
|
@@ -324,6 +343,29 @@ pub struct SentMediaInfo { | |
| /// | ||
| /// When uploading a thumbnail, this is set to `None`. | ||
| pub thumbnail: Option<MediaSource>, | ||
|
|
||
| /// Accumulated list of infos for previously uploaded files and thumbnails | ||
| /// if used during a gallery transaction. Otherwise empty. | ||
| #[cfg(feature = "unstable-msc4274")] | ||
| #[serde(default)] | ||
| pub accumulated: Vec<AccumulatedSentMediaInfo>, | ||
|
Comment on lines
+348
to
+352
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be a different possible data scheme here, if I understand correctly:
Again, I see this struct
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think technically this would work, yes. I didn't go for it originally because I wanted to minimize breaking changes and because it felt slightly cleaner to have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only advantage is technical, in that it avoids containing what's effectively another flattened I'm a bit torn, because this is likely a non-trivial change, but on the other hand that might be a nice simplification. Maybe that could be attempted as a follow-up, and we could open an issue to not forget about it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I see the oddness. Sounds good on the issue. I have opened: #4969 |
||
| } | ||
|
|
||
| /// Accumulated information about a media (and its thumbnail) that have been | ||
| /// sent to a homeserver. | ||
| #[cfg(feature = "unstable-msc4274")] | ||
| #[derive(Clone, Debug, Serialize, Deserialize)] | ||
| pub struct AccumulatedSentMediaInfo { | ||
| /// File that was uploaded by this request. | ||
| /// | ||
| /// If the request related to a thumbnail upload, this contains the | ||
| /// thumbnail media source. | ||
| pub file: MediaSource, | ||
|
|
||
| /// Optional thumbnail previously uploaded, when uploading a file. | ||
| /// | ||
| /// When uploading a thumbnail, this is set to `None`. | ||
| pub thumbnail: Option<MediaSource>, | ||
|
bnjbvr marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /// A unique key (identifier) indicating that a transaction has been | ||
|
|
@@ -390,7 +432,7 @@ impl DependentQueuedRequest { | |
| DependentQueuedRequestKind::EditEvent { .. } | ||
| | DependentQueuedRequestKind::RedactEvent | ||
| | DependentQueuedRequestKind::ReactEvent { .. } | ||
| | DependentQueuedRequestKind::UploadFileWithThumbnail { .. } => { | ||
| | DependentQueuedRequestKind::UploadFileOrThumbnail { .. } => { | ||
| // These are all aggregated events, or non-visible items (file upload producing | ||
| // a new MXC ID). | ||
| false | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.