Page MenuHomePhabricator

[keyserver] Introduce responder validators
ClosedPublic

Authored by michal on Apr 29 2023, 3:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 4, 4:13 PM
Unknown Object (File)
Mon, Nov 4, 12:20 PM
Unknown Object (File)
Mon, Nov 4, 12:19 PM
Unknown Object (File)
Mon, Oct 28, 8:38 AM
Unknown Object (File)
Oct 25 2024, 7:21 AM
Unknown Object (File)
Oct 20 2024, 11:14 AM
Unknown Object (File)
Oct 20 2024, 11:14 AM
Unknown Object (File)
Oct 10 2024, 5:30 PM
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