-
Notifications
You must be signed in to change notification settings - Fork 117
ref(server): Remove unnecessary old code for splitting envelopes #6023
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
Open
Dav1dde
wants to merge
10
commits into
master
Choose a base branch
from
dav1d/processing-cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
496f015
wip
Dav1dde d1a9a65
split raw security into multiple envelope
Dav1dde 412e811
cleanup tests and errors
Dav1dde 795a857
more cleanup and comments
Dav1dde c5b4b9b
cogs and invalid envelope/item handling
Dav1dde b039e8d
debug assert doesn't work
Dav1dde da13944
undo the nothing changes
Dav1dde 42590d2
keep DS comment around
Dav1dde 5eb1f07
explicit noop token
Dav1dde 0c8be51
update envelope
Dav1dde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| use relay_cogs::{AppFeature, FeatureWeights}; | ||
|
|
||
| use crate::envelope::{Item, ItemType}; | ||
| use crate::managed::{Counted, Managed, ManagedEnvelope, OutcomeError, Quantities, Rejected}; | ||
| use crate::processing::{self, Context, Nothing, Output}; | ||
| use crate::services::outcome::{DiscardReason, Outcome}; | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| #[error("the item is not allowed/supported in this envelope")] | ||
| pub struct InvalidItem; | ||
|
|
||
| impl OutcomeError for InvalidItem { | ||
| type Error = Self; | ||
|
|
||
| fn consume(self) -> (Option<crate::services::outcome::Outcome>, Self::Error) { | ||
| (Some(Outcome::Invalid(DiscardReason::InvalidEnvelope)), self) | ||
| } | ||
| } | ||
|
|
||
| /// A processor which rejects unhandled invalid items. | ||
| /// | ||
| /// This processor accepts certain envelope items which may be mixed into envelopes incorrectly. | ||
| #[derive(Debug)] | ||
| pub struct InvalidUnhandledProcessor { | ||
| _priv: (), | ||
| } | ||
|
|
||
| impl InvalidUnhandledProcessor { | ||
| /// Creates a new [`Self`]. | ||
| pub fn new() -> Self { | ||
| Self { _priv: () } | ||
| } | ||
| } | ||
|
|
||
| impl processing::Processor for InvalidUnhandledProcessor { | ||
| type Input = InvalidUnhandledItems; | ||
| type Output = Nothing; | ||
| type Error = InvalidItem; | ||
|
|
||
| fn cogs() -> FeatureWeights { | ||
| AppFeature::UnattributedEnvelope.into() | ||
| } | ||
|
|
||
| fn prepare_envelope(&self, envelope: &mut ManagedEnvelope) -> Option<Managed<Self::Input>> { | ||
| let invalid_items = envelope | ||
| .envelope_mut() | ||
| // `FormData` only makes sense together with an item which creates an event, | ||
| // if it's mixed into an envelope which does not create an event, it is invalid. | ||
| .take_items_by(|item| matches!(*item.ty(), ItemType::FormData)) | ||
| .into_vec(); | ||
|
|
||
| if invalid_items.is_empty() { | ||
| return None; | ||
| } | ||
|
|
||
| Some(Managed::with_meta_from_managed_envelope( | ||
| envelope, | ||
| InvalidUnhandledItems { invalid_items }, | ||
| )) | ||
| } | ||
|
|
||
| async fn process( | ||
| &self, | ||
| invalid: Managed<Self::Input>, | ||
| _ctx: Context<'_>, | ||
| ) -> Result<Output<Self::Output>, Rejected<Self::Error>> { | ||
| Err(invalid.reject_err(InvalidItem)) | ||
| } | ||
| } | ||
|
|
||
| /// Unknown items extracted from an envelope. | ||
| #[derive(Debug)] | ||
| pub struct InvalidUnhandledItems { | ||
| /// List of unknown envelope items. | ||
| pub invalid_items: Vec<Item>, | ||
| } | ||
|
|
||
| impl Counted for InvalidUnhandledItems { | ||
| fn quantities(&self) -> Quantities { | ||
| self.invalid_items.quantities() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.