Allow updating messages in storage#183
Conversation
This is useful to update messages with additional properties set in the pipeline
There was a problem hiding this comment.
Pull Request Overview
Allow updating messages in storage by replacing existing entries instead of always appending, and add a test to verify this behavior.
- Replace existing message in a conversation when IDs match.
- Update test project’s C# language version to Preview.
- Add a test that verifies updating an existing message’s additional properties.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/WhatsApp/ConversationStorage.cs | Add logic to find and replace an existing message in the conversation before saving. |
| src/Tests/Tests.csproj | Bump LangVersion to Preview in the test project. |
| src/Tests/ConversationStorageTests.cs | Add a test case to ensure that updating a message preserves both new and existing properties. |
|
|
||
| message.AdditionalProperties?["Agent"] = "Calendar"; | ||
|
|
||
| await storage.SaveAsync(message); |
There was a problem hiding this comment.
The test calls SaveAsync without providing a CancellationToken, but the implementation requires one. Either add an overload with a default token or update the test to pass a valid CancellationToken.
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <LangVersion>Preview</LangVersion> |
There was a problem hiding this comment.
[nitpick] Requiring the C# Preview language version in tests may introduce instability; consider targeting a specific stable LangVersion unless new preview features are strictly needed.
| <LangVersion>Preview</LangVersion> | |
| <LangVersion>latest</LangVersion> |
🧪 Details on Ubuntu 24.04.2 LTSfrom dotnet-retest v0.7.1 on .NET 8.0.17 with 💜 by @devlooped |
Allow updating messages in storage
This is useful to update messages with additional properties set in the pipeline