You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api types [nfc]: Add rawModelTypes.js, for getMessages's ServerMessage, etc.
getMessages is a binding for the GET /messages endpoint. We're about
to add a binding for the GET /message/{message_id} endpoint, which
since zulip/zulip@82837304e (FL 120) has given us a full message
object in the same shape.
For both bindings, we want:
(a) a type to describe the data given by the server to represent a
message (ServerMessage before this commit), and
(b) a function to transform that data into our Message type
(migrateMessage before this commit).
And it's good to deduplicate both (a) and (b), in part because any
differences would be surprising and warrant investigation; see
discussion:
#5465 (comment)
The old code was already clear that it was about fetched data, not
data from events, because it was in the file that defined
api.getMessages. Keep that meaning intact by making the names more
specific:
ServerMessage → FetchedMessage
(the "server" part is clear from the new file's name)
migrateMessage → transformFetchedMessage
(the orthogonal change from "migrate" to "transform" should help
prevent confusion with src/storage/migrations.js, which has
nothing to do with what this function does.)
It's useful to remember that this code was developed specifically
for these fetch-message(s) endpoints, e.g., for a future
investigation aiming to deduplicate most of the corresponding
'message'-event code with this code.
(That last bit reminds me that we don't even have a deliberate type
for how we expect servers to represent a message in 'message'
events. I'll write a TODO for that in the next commit.)
0 commit comments