Page MenuHomePhabricator

[lib] Add httpMessageUserInfosHandler
ClosedPublic

Authored by inka on May 16 2024, 6:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 9, 1:44 AM
Unknown Object (File)
Sat, Nov 9, 1:44 AM
Unknown Object (File)
Sat, Nov 9, 1:44 AM
Unknown Object (File)
Sat, Nov 9, 1:43 AM
Unknown Object (File)
Sat, Nov 9, 12:25 AM
Unknown Object (File)
Fri, Nov 1, 7:58 PM
Unknown Object (File)
Sun, Oct 27, 1:37 PM
Unknown Object (File)
Oct 2 2024, 5:51 PM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

inka requested review of this revision.May 16 2024, 7:06 AM
lib/handlers/http-message-user-infos-handler.js
31 ↗(On Diff #40285)

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

tomek added inline comments.
lib/handlers/http-message-user-infos-handler.js
18–20 ↗(On Diff #40285)

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

35–37 ↗(On Diff #40285)

Should we memoize the validators?

40 ↗(On Diff #40285)

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 ↗(On Diff #40285)

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.