Page MenuHomePhabricator

[keyserver] Introduce responder validators
ClosedPublic

Authored by michal on Apr 29 2023, 3:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 4:15 PM
Unknown Object (File)
Fri, Apr 12, 4:23 PM
Unknown Object (File)
Wed, Apr 10, 9:02 AM
Unknown Object (File)
Fri, Apr 5, 4:59 AM
Unknown Object (File)
Fri, Apr 5, 4:59 AM
Unknown Object (File)
Fri, Apr 5, 4:59 AM
Unknown Object (File)
Fri, Apr 5, 4:59 AM
Unknown Object (File)
Fri, Apr 5, 4:58 AM
Subscribers

Details

Summary

Introduce validators for entry, keys, siwe, message report, relationship and search responders and tests, most of which are taken from real requests that I've logged. I decided to not split it in multiple diffs because it's mostly just 1-2 validators per responder type and each change is localized to the responder.

Test Plan

yarn jest

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

keyserver/src/responders/entry-responders.js
131–135 ↗(On Diff #25930)
export type FetchEntryInfosBase = {
  +rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,
};
export type FetchEntryInfosResponse = {
  ...FetchEntryInfosBase,
  +userInfos: { [id: string]: AccountUserInfo },
};
154–157 ↗(On Diff #25930)
export type FetchEntryRevisionInfosResult = {
  +result: $ReadOnlyArray<HistoryRevisionInfo>,
};
179–184 ↗(On Diff #25930)
export type SaveEntryResponse = {
  +entryID: string,
  +newMessageInfos: $ReadOnlyArray<RawMessageInfo>,
  +updatesResult: ServerCreateUpdatesResponse,
};
221–227 ↗(On Diff #25930)
export type DeleteEntryResponse = {
  +newMessageInfos: $ReadOnlyArray<RawMessageInfo>,
  +threadID: string,
  +updatesResult: ServerCreateUpdatesResponse,
};
244–248 ↗(On Diff #25930)
export type RestoreEntryResponse = {
  +newMessageInfos: $ReadOnlyArray<RawMessageInfo>,
  +updatesResult: ServerCreateUpdatesResponse,
};
259–264 ↗(On Diff #25930)
export type DeltaEntryInfosResult = {
  +rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,
  +deletedEntryIDs: $ReadOnlyArray<string>,
  +userInfos: $ReadOnlyArray<AccountUserInfo>,
};
keyserver/src/responders/message-report-responder.js
20–21 ↗(On Diff #25930)
export type MessageReportCreationResult = {
  +messageInfo: RawMessageInfo,
};
keyserver/src/responders/relationship-responders.js
21–27 ↗(On Diff #25930)
export type RelationshipErrors = $Shape<{
  invalid_user: string[],
  already_friends: string[],
  user_blocked: string[],
}>;
keyserver/src/responders/search-responders.js
20–23 ↗(On Diff #25930)
export type UserSearchResult = {
  userInfos: $ReadOnlyArray<GlobalAccountUserInfo>,
};
keyserver/src/responders/siwe-nonce-responders.js
11–12 ↗(On Diff #25930)
export type SIWENonceResponse = {
  +nonce: string,
};
tomek requested changes to this revision.May 4 2023, 5:28 AM
tomek added inline comments.
keyserver/src/responders/entry-responders.js
263 ↗(On Diff #26063)

In the original type this is a list

keyserver/src/responders/relationship-responders.js
21–27 ↗(On Diff #25930)

Do we know why underscores are used here?

This revision now requires changes to proceed.May 4 2023, 5:28 AM
keyserver/src/responders/relationship-responders.js
21–27 ↗(On Diff #25930)

I don't exactly remember why we chose to use underscores here, but I know it's been like this since it was implemented

Fix deltaEntryInfosResultValidator

This revision is now accepted and ready to land.May 4 2023, 8:14 AM