-
Notifications
You must be signed in to change notification settings - Fork 14
Add bridge method to upload group images #704
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
Conversation
WalkthroughAdds a new cross-language API to upload a group image, including Dart and Rust endpoints, result types, and (de)serialization for a new fixed-size byte array (12 bytes). Updates FFI dispatch IDs, codegen metadata, and Rust dependencies. Introduces UploadGroupImageResult and U8Array12 types across layers. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as Dart App
participant API as Dart API (groups.dart)
participant FRB as Dart FRB (frb_generated.dart)
participant Wire as FRB Wire (rust frb_generated.rs)
participant Svc as Rust API (groups.rs)
participant WN as Whitenoise
participant Srv as Server
App->>API: uploadGroupImage(accountPubkey, groupId, filePath, imageType, serverUrl)
API->>FRB: crateApiGroupsUploadGroupImage(...)
FRB->>Wire: SSE call (funcId 59, args)
Wire->>Svc: upload_group_image(...)
Svc->>WN: upload_group_image(account, group, file, type, url)
WN->>Srv: Upload image bytes
Srv-->>WN: Encrypted hash/key/nonce
WN-->>Svc: Result {encrypted_hash, image_key, image_nonce}
Svc-->>Wire: UploadGroupImageResult
Wire-->>FRB: SSE encode result
FRB-->>API: UploadGroupImageResult
API-->>App: UploadGroupImageResult (U8Array32, U8Array32, U8Array12)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
rust/Cargo.toml (1)
19-19: Git deps pinned; consider removing redundantversionwithgit+rev.Cargo ignores
versionwhengitis specified. Droppingversionavoids confusion and lockfile churn.Also applies to: 32-32
lib/src/rust/api/groups.dart (1)
85-98: Wrapper method wiring is correct. Consider typingimageType.Arg order matches Rust; call path is correct. Recommend replacing the String
imageTypewith a typed enum to avoid magic strings and runtime parse errors.As per coding guidelines
rust/src/api/groups.rs (1)
9-11: New API and result struct are coherent and safe-by-default. Consider enum for image type.
- Flow: get_instance → parse inputs → call whitenoise → return tuple → struct — good.
- Suggest accepting a typed image enum instead of
Stringand converting towhitenoise::ImageType. Avoids stringly-typed interface and centralizes validation.Example (outside the shown range):
#[frb] #[derive(Debug, Clone)] pub enum FlutterImageType { Png, Jpeg } impl From<FlutterImageType> for ImageType { fn from(x: FlutterImageType) -> Self { match x { FlutterImageType::Png => ImageType::Png, FlutterImageType::Jpeg => ImageType::Jpeg } } }Then adjust signature within this range:
- image_type: String, + image_type: FlutterImageType,and convert with
let image_type: ImageType = image_type.into();.As per coding guidelines
Also applies to: 343-376
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
rust/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
lib/src/rust/api/groups.dart(3 hunks)lib/src/rust/frb_generated.dart(12 hunks)lib/src/rust/frb_generated.io.dart(3 hunks)lib/src/rust/lib.dart(1 hunks)rust/Cargo.toml(2 hunks)rust/src/api/groups.rs(2 hunks)rust/src/frb_generated.rs(8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.dart
📄 CodeRabbit inference engine (.cursor/rules/flutter.mdc)
**/*.dart: Always declare the type of each variable and function (parameters and return value). Avoid using 'any'. Create necessary types.
Don't leave blank lines within a function.
One export per file.
Use PascalCase for classes.
Use camelCase for variables, functions, and methods.
Use underscores_case for file and directory names.
Use UPPERCASE for environment variables. Avoid magic numbers and define constants.
Start each function with a verb.
Use verbs for boolean variables. Example: isLoading, hasError, canDelete, etc.
Use complete words instead of abbreviations and correct spelling, except for standard and well-known abbreviations (API, URL, i, j, err, ctx, req, res, next).
Write short functions with a single purpose. Less than 20 instructions.
Name functions with a verb and something else. If it returns a boolean, use isX or hasX, canX, etc. If it doesn't return anything, use executeX or saveX, etc.
Avoid nesting blocks by early checks and returns, or extraction to utility functions.
Use higher-order functions (map, filter, reduce, etc.) to avoid function nesting. Use arrow functions for simple functions (less than 3 instructions). Use named functions for non-simple functions.
Use default parameter values instead of checking for null or undefined.
Reduce function parameters using RO-RO: use an object to pass multiple parameters and to return results. Declare necessary types for input arguments and output.
Use a single level of abstraction in functions.
Don't abuse primitive types and encapsulate data in composite types.
Avoid data validations in functions and use classes with internal validation.
Prefer immutability for data. Use readonly for data that doesn't change. Use 'as const' for literals that don't change.
Declare interfaces to define contracts.
Write small classes with a single purpose. Less than 200 instructions, less than 10 public methods, less than 10 properties.
Use exceptions to handle errors you don't expect. If you catch an exception, it sh...
Files:
lib/src/rust/api/groups.dartlib/src/rust/lib.dartlib/src/rust/frb_generated.io.dartlib/src/rust/frb_generated.dart
🧬 Code graph analysis (2)
rust/src/frb_generated.rs (1)
rust/src/api/groups.rs (1)
upload_group_image(353-376)
rust/src/api/groups.rs (1)
rust/src/api/utils.rs (1)
group_id_from_string(56-59)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Flutter CI
🔇 Additional comments (3)
lib/src/rust/lib.dart (1)
11-21: U8Array12 addition mirrors U8Array32 — looks good.Assertions and constructors align with existing pattern.
lib/src/rust/api/groups.dart (1)
233-255: UploadGroupImageResult shape matches Rust — LGTM.Fields/types align with bridge types.
lib/src/rust/frb_generated.dart (1)
80-80: Verified Bridge wiring and codecs for U8Array12/UploadGroupImageResult: Rust fn, result struct, Dart API stub, and DCO/SSE codecs are all present and funcIds 58–62 are sequential.
Summary by CodeRabbit
New Features
Chores