Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tipogi committed Jan 22, 2025
1 parent 02c9d60 commit d46e9b0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ impl Event {

let uri = parts[1].to_string();
let parsed_uri = ParsedUri::try_from(uri.as_str())?;
println!("ParsedURI: {:?}", parsed_uri);

//TODO: This conversion to a match statement that only uses IF conditions is silly.
// We could be patter matching the split test for "posts", "follows", etc maybe?
Expand All @@ -108,30 +107,30 @@ impl Event {
post_id: parsed_uri
.post_id
.ok_or(EventProcessorError::InvalidEventLine {
message: format!("Missing post_id, {} {}", parts[0], uri),
message: format!("Missing post_id, {}", line),
})?,
},
_ if uri.contains("/follows/") => ResourceType::Follow {
follower_id: parsed_uri.user_id,
followee_id: parsed_uri
.follow_id
.ok_or(EventProcessorError::InvalidEventLine {
message: format!("Missing followee_id, {} {}", parts[0], uri),
message: format!("Missing followee_id, {}", line),
})?,
},
_ if uri.contains("/mutes/") => ResourceType::Mute {
user_id: parsed_uri.user_id,
muted_id: parsed_uri
.muted_id
.ok_or(EventProcessorError::InvalidEventLine {
message: format!("Missing muted_id, {} {}", parts[0], uri),
message: format!("Missing muted_id, {}", line),
})?,
},
_ if uri.contains("/bookmarks/") => ResourceType::Bookmark {
user_id: parsed_uri.user_id,
bookmark_id: parsed_uri.bookmark_id.ok_or(
EventProcessorError::InvalidEventLine {
message: format!("Missing bookmark_id, {} {}", parts[0], uri),
message: format!("Missing bookmark_id, {}", line),
},
)?,
},
Expand All @@ -140,23 +139,24 @@ impl Event {
tag_id: parsed_uri
.tag_id
.ok_or(EventProcessorError::InvalidEventLine {
message: format!("Missing tag_id, {} {}", parts[0], uri),
message: format!("Missing tag_id, {}", line),
})?,
},
_ if uri.contains("/files/") => ResourceType::File {
user_id: parsed_uri.user_id,
file_id: parsed_uri
.file_id
.ok_or(EventProcessorError::InvalidEventLine {
message: format!("Missing file_id, {} {}", parts[0], uri),
message: format!("Missing file_id, {}", line),
})?,
},
_ if uri.contains("/blobs") => return Ok(None),
_ if uri.contains("/last_read") => return Ok(None),
_ if uri.contains("/settings") => return Ok(None),
_ if uri.contains("/feeds") => return Ok(None),
_ => {
return Err(EventProcessorError::InvalidEventLine {
message: format!("Unrecognized resource in URI, {} {}", parts[0], uri),
message: format!("Unrecognized resource in URI, {}", line),
}
.into())
}
Expand Down

0 comments on commit d46e9b0

Please sign in to comment.