fix: e2ee keys not exported correctly#204
Conversation
|
| if errStatus := lineGroupE2EEReconnectRequiredError(err); errStatus != nil { | ||
| return errStatus | ||
| } | ||
| return err |
There was a problem hiding this comment.
Behavior change worth confirming: Previously the two group-encrypt branches only aborted on ErrMissingOwnPrivateKey and logged/ignored every other fetchAndUnwrapGroupKey error, so a transient LINE API failure (e.g. getChats failed for X: connection refused, autoRegisterGroupKey failure, token-recovery failure) would fall through to EncryptGroupMessage with cached state or eventually the plaintext fallback at line 605.
With lineGroupE2EEFetchFailureError, any non-NoUsableE2EEGroupKey error is now returned as-is to Matrix (unwrapped — no MessageStatus, no reconnect notice), which:
- Turns transient errors into hard user-visible send failures instead of best-effort delivery.
- Skips the plaintext-fallback path in the retry branch (line ~605) entirely for these errors.
- Surfaces raw
fmt.Errorfstrings like"getChats failed for X: %w"to end users instead of the actionable reconnect notice.
If the intent is only to bubble reconnect-required errors, consider returning nil (instead of err) from the default branch of lineGroupE2EEFetchFailureError to preserve the previous "log and continue" semantics.
|
|
||
| ll.fetchLoginKeys(res, meta, client) | ||
| exportedKeys := ll.fetchLoginKeys(res, meta, client) | ||
| if !exportedKeys && ll.ExistingMetadata != nil && len(ll.ExistingMetadata.ExportedKeyMap) > 0 { |
There was a problem hiding this comment.
Latent: this copy has no !res.NoE2EE guard, so if the new LoginResult is LSOFF (res.NoE2EE == true) with an empty keychain but the previous metadata was LSON, meta ends up with a full E2EE block on a NoE2EE login. In practice accounts rarely downgrade LSON→LSOFF, but the guard on line 452 (!res.NoE2EE && len(meta.ExportedKeyMap) == 0) implies you already treat those two states as mutually exclusive — consider gating the copy on !res.NoE2EE too so downstream code doesn't get contradictory metadata.
| ll.User.Bridge.Log.Info().Int("keys", len(meta.ExportedKeyMap)).Msg("Preserved existing E2EE keys after re-login") | ||
| } | ||
| if !res.NoE2EE && len(meta.ExportedKeyMap) == 0 { | ||
| return nil, fmt.Errorf("LINE login completed without E2EE keychain; please reconnect again and complete the LINE verification prompt") |
There was a problem hiding this comment.
Nit: every other user-facing failure in this file returns via ll.loginErrorStep(...) (see lines 205, 222, 248) so the user gets a re-prompt with the error message inline. This branch instead returns a raw fmt.Errorf, which bubbles up to the bridge framework as a plain error string — less actionable UX than the surrounding paths.
No description provided.