Refactor DbHelper connection handling#28
Refactor DbHelper connection handling#28harbor208199 wants to merge 5 commits intomichal-kapala:masterfrom
Conversation
|
I dug further into the code and noticed that Invitations were never serialized because GameSessionInvitationReceived.ToBuffer still threw NotImplementedException even though GetInvitationsReceived tried to serialize each invite, every fetch would fail.
|
|
@harbor208199 I believe we've previously seen a bug where 2 users can send friend requests to each other, so we end up with the same 2 users having 2 pending invitations. If both users then accept those, they are on each other's friend lists twice |
Yep, that's still the case. |
|
Exactly, that's what this change tightens up, AddFriend now only promotes when there's a real pending invite from requester to requestee, so you can't accept an arbitrary PID and each accept just flips its own pending row. That should prevent the double friend scenario you've seen, and avoid needing a restart |
That's awesome! I'll hopefully get a good look into these changes in a few hours |
|
Follow up: kept the pending invite requirement and now collapse any duplicate relationship rows into single Friend entry on acceptance |
DbHelper relied on a single static SQLite connection and interpolated user data into SQL, which risks "database is locked" failures, leaked handles, and SQL injection. It also mapped UbiId incorrectly.
This refactor adds scoped connections, parameterized commands, and correct field mapping without changing any public API
Added a CreateConnection() helper and wrapped every DbHelper method in using blocks so each operation opens/closes its own SQLite connection and logs init failures.
Updated all raw SQL (privilege lookup, telemetry inserts, messaging/invite helpers) to use parameterized SQLiteCommand to avoid injection/quoting issues
Fixed GetUserByName / GetUserByID to populate UbiId from the ubi_id column instead of the password field.