Page MenuHomePhabricator

[identity] [5/n] Create search result message type for identity search
ClosedPublic

Authored by will on Jan 26 2024, 2:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 13, 2:30 AM
Unknown Object (File)
Wed, Nov 13, 2:30 AM
Unknown Object (File)
Oct 26 2024, 1:22 AM
Unknown Object (File)
Oct 23 2024, 2:32 AM
Unknown Object (File)
Oct 22 2024, 4:58 PM
Unknown Object (File)
Oct 22 2024, 4:58 PM
Unknown Object (File)
Oct 22 2024, 4:58 PM
Unknown Object (File)
Oct 22 2024, 4:58 PM
Subscribers

Details

Summary

This creates a search result type in shared and uses it in the identity search websocket server

Depends on 10848

Test Plan

Successfully tested on local dev. Prefix queries return correct response

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

will held this revision as a draft.
shared/identity_search_messages/src/messages/search_result.rs
15 ↗(On Diff #36200)

Not sure if convention dictates if payload should be a String. I can change this to another name like "results" or "hits"

will published this revision for review.Jan 29 2024, 9:31 AM
will retitled this revision from [services] Create search result message type for identity search to [services] [5/n] Create search result message type for identity search.
will edited the summary of this revision. (Show Details)
will retitled this revision from [services] [5/n] Create search result message type for identity search to [identity] [5/n] Create search result message type for identity search.Jan 30 2024, 11:07 AM
shared/identity_search_messages/src/messages/search_result.rs
6 ↗(On Diff #36200)

Should I tag this with its type? As in, should I put
#[serde(tag = "type")]

bartek requested changes to this revision.Jan 31 2024, 2:19 AM
bartek added a subscriber: kamil.

Requesting because I think SearchResult should be added to the Messages enum. Correct me if I'm wrong

shared/identity_search_messages/src/messages/mod.rs
16 ↗(On Diff #36200)

Shouldn't you add this SearchResult to this enum?

shared/identity_search_messages/src/messages/search_result.rs
6 ↗(On Diff #36200)

No, adding #[serde(tag = "type")] means that when you serialize/deserialize this, the JSON would add a field called type:

{
  "type": "User",
  "userID": "foo",
  "username": "bar"
}

This makes sense e.g. for Tunnelbroker messages, when you have a big enum of various message types and thanks to the type field, it knows what message it is deserializing.

There's no purpose of adding it here since User is only used as an inner type of SearchResult

15 ↗(On Diff #36200)

The payload is probably Tunnelbroker-specific convention, so it's mostly up to you.
cc @kamil, are there any other things to consider regarding naming?

This revision now requires changes to proceed.Jan 31 2024, 2:19 AM
shared/identity_search_messages/src/messages/mod.rs
16 ↗(On Diff #36200)

Originally, I had this removed as I'm utilizing Messages to deserialize client messages to server. However, I can just only match on AuthMessage, SearchQuery, and Heartbeat. Will add SearchResult

shared/identity_search_messages/src/messages/search_result.rs
15 ↗(On Diff #36200)

Got it. I'll go with "hits" then as it is more specific to identity search.

Add SearchResult to Messages

bartek added inline comments.
shared/identity_search_messages/src/messages/mod.rs
16 ↗(On Diff #36200)

I'm utilizing Messages to deserialize client messages to server.

Yeah, so adding this adds possibility to deserialize server messages on clients too ;)

However, I can just only match on AuthMessage, SearchQuery, and Heartbeat.

Exactly, you can always match all unrelated types with _ => Err(unexpected message)

This revision is now accepted and ready to land.Jan 31 2024, 11:34 AM