Page MenuHomePhabricator

[keyserver] Introduce responder validators
ClosedPublic

Authored by michal on Apr 29 2023, 3:46 AM.
Tags
None
Referenced Files
F3382157: D7685.diff
Thu, Nov 28, 8:47 AM
Unknown Object (File)
Mon, Nov 25, 8:56 PM
Unknown Object (File)
Mon, Nov 25, 8:56 PM
Unknown Object (File)
Mon, Nov 25, 8:56 PM
Unknown Object (File)
Mon, Nov 25, 8:18 PM
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
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
No Lint Coverage
Unit
No Test Coverage

Event Timeline

keyserver/src/responders/entry-responders.js
131–135
export type FetchEntryInfosBase = {
  +rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,
};
export type FetchEntryInfosResponse = {
  ...FetchEntryInfosBase,
  +userInfos: { [id: string]: AccountUserInfo },
};
154–157
export type FetchEntryRevisionInfosResult = {
  +result: $ReadOnlyArray<HistoryRevisionInfo>,
};
179–184
export type SaveEntryResponse = {
  +entryID: string,
  +newMessageInfos: $ReadOnlyArray<RawMessageInfo>,
  +updatesResult: ServerCreateUpdatesResponse,
};
221–227
export type DeleteEntryResponse = {
  +newMessageInfos: $ReadOnlyArray<RawMessageInfo>,
  +threadID: string,
  +updatesResult: ServerCreateUpdatesResponse,
};
244–248
export type RestoreEntryResponse = {
  +newMessageInfos: $ReadOnlyArray<RawMessageInfo>,
  +updatesResult: ServerCreateUpdatesResponse,
};
259–264
export type DeltaEntryInfosResult = {
  +rawEntryInfos: $ReadOnlyArray<RawEntryInfo>,
  +deletedEntryIDs: $ReadOnlyArray<string>,
  +userInfos: $ReadOnlyArray<AccountUserInfo>,
};
keyserver/src/responders/message-report-responder.js
20–21
export type MessageReportCreationResult = {
  +messageInfo: RawMessageInfo,
};
keyserver/src/responders/relationship-responders.js
21–27
export type RelationshipErrors = $Shape<{
  invalid_user: string[],
  already_friends: string[],
  user_blocked: string[],
}>;
keyserver/src/responders/search-responders.js
20–23
export type UserSearchResult = {
  userInfos: $ReadOnlyArray<GlobalAccountUserInfo>,
};
keyserver/src/responders/siwe-nonce-responders.js
11–12
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

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

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