Page MenuHomePhabricator

[lib] Add httpMessageUserInfosHandler
ClosedPublic

Authored by inka on May 16 2024, 6:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 6:35 PM
Unknown Object (File)
Mon, Dec 16, 6:35 PM
Unknown Object (File)
Mon, Dec 16, 6:35 PM
Unknown Object (File)
Mon, Dec 16, 6:35 PM
Unknown Object (File)
Mon, Dec 16, 6:35 PM
Unknown Object (File)
Mon, Dec 16, 6:34 PM
Unknown Object (File)
Nov 14 2024, 9:40 AM
Unknown Object (File)
Nov 14 2024, 9:22 AM
Subscribers

Details

Summary

issue: ENG-7821
This function will be called on the result of fetch in callSingleKeyserverEndpoint
Responders return values which are validated on the keyserver side inside the responder functions created by createJSONResponder. The validated response is then returned to either:

  • handleAPIRequestClientSocketMessage in case of socket requests
  • jsonHandler in case of http requests

Following what those functions do with the result, we can tell what fields are being appended before being sent to the client. Those fields are: success, cookieChange, and in the case of an exception: error and payload.
But none of the fields have to be added. So we add those fields to the validator as optional

Test Plan

Tested with the next diff - called this function on the result of fetch and checked that user ids are correctly extracted from respones

Diff Detail

Repository
rCOMM Comm
Branch
inka/userStore
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

inka requested review of this revision.May 16 2024, 7:06 AM
lib/handlers/http-message-user-infos-handler.js
31

I think this could have a better name... maybe extractAndPersistUserInfosFromMessages?

tomek added inline comments.
lib/handlers/http-message-user-infos-handler.js
18–20

Are all these fields mandatory? I can see that e.g. RegisterResponse doesn't have cookieInvalidated flag.

35–37

Should we memoize the validators?

40

We will need to figure out how to get the dispatch function. We can't use hooks here.

This revision is now accepted and ready to land.May 17 2024, 6:08 AM
lib/handlers/http-message-user-infos-handler.js
40

We use this only in callSingleKeyserverEndpoint, which has access to dispatch and can pass it in

Memoize validators, rename and fix types

This revision was automatically updated to reflect the committed changes.