Import/export gift badges, other fields

This commit is contained in:
Fedor Indutny 2024-06-12 13:36:02 -07:00 committed by GitHub
parent af1c593fef
commit e6b62001d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 536 additions and 55 deletions

View file

@ -93,36 +93,39 @@ function sortAndNormalize(
return result;
}
return {
...rest,
conversationId: mapConvoId(conversationId),
reactions: reactions?.map(({ fromId, ...restOfReaction }) => {
return {
from: mapConvoId(fromId),
...restOfReaction,
};
}),
changedId: mapConvoId(changedId),
key_changed: mapConvoId(keyChanged),
verifiedChanged: mapConvoId(verifiedChanged),
sendStateByConverationId: mapSendState(sendStateByConversationId),
editHistory: editHistory?.map(history => {
const {
sendStateByConversationId: historySendState,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
received_at: _receivedAtHistory,
...restOfHistory
} = history;
// Get rid of unserializable `undefined` values.
return JSON.parse(
JSON.stringify({
...rest,
conversationId: mapConvoId(conversationId),
reactions: reactions?.map(({ fromId, ...restOfReaction }) => {
return {
from: mapConvoId(fromId),
...restOfReaction,
};
}),
changedId: mapConvoId(changedId),
key_changed: mapConvoId(keyChanged),
verifiedChanged: mapConvoId(verifiedChanged),
sendStateByConverationId: mapSendState(sendStateByConversationId),
editHistory: editHistory?.map(history => {
const {
sendStateByConversationId: historySendState,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
received_at: _receivedAtHistory,
...restOfHistory
} = history;
return {
...restOfHistory,
sendStateByConversationId: mapSendState(historySendState),
};
}),
return {
...restOfHistory,
sendStateByConversationId: mapSendState(historySendState),
};
}),
// Not an original property, but useful
isUnsupported: isUnsupportedMessage(message),
};
// Not an original property, but useful
isUnsupported: isUnsupportedMessage(message),
})
);
});
}