mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Add IDs to JSON exports (#5426)
* Added IDs to various JSON objects. Including an `_id` addition inside chat message, which get appended to `actor` or `from` entries.
This commit is contained in:
parent
61add763ae
commit
87d4d46ce7
3 changed files with 10 additions and 2 deletions
|
@ -617,6 +617,7 @@ User ParseUser(const MTPUser &data) {
|
|||
auto result = User();
|
||||
result.info = ParseContactInfo(data);
|
||||
data.match([&](const MTPDuser &data) {
|
||||
result.id = data.vid.v;
|
||||
if (data.has_username()) {
|
||||
result.username = ParseString(data.vusername);
|
||||
}
|
||||
|
|
|
@ -189,6 +189,7 @@ UserpicsSlice ParseUserpicsSlice(
|
|||
struct User {
|
||||
ContactInfo info;
|
||||
Utf8String username;
|
||||
int32 id;
|
||||
bool isBot = false;
|
||||
bool isSelf = false;
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ QByteArray SerializeMessage(
|
|||
|
||||
if (message.media.content.is<UnsupportedMedia>()) {
|
||||
return SerializeObject(context, {
|
||||
{ "id", NumberToString(message.id) },
|
||||
{ "id", Data::NumberToString(message.id) },
|
||||
{ "type", SerializeString("unsupported") }
|
||||
});
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ QByteArray SerializeMessage(
|
|||
};
|
||||
const auto push = [&](const QByteArray &key, const auto &value) {
|
||||
if constexpr (std::is_arithmetic_v<std::decay_t<decltype(value)>>) {
|
||||
pushBare(key, NumberToString(value));
|
||||
pushBare(key, Data::NumberToString(value));
|
||||
} else {
|
||||
const auto wrapped = QByteArray(value);
|
||||
if (!wrapped.isEmpty()) {
|
||||
|
@ -288,6 +288,7 @@ QByteArray SerializeMessage(
|
|||
const auto pushFrom = [&](const QByteArray &label = "from") {
|
||||
if (message.fromId) {
|
||||
pushBare(label, wrapUserName(message.fromId));
|
||||
pushBare(label+"_id", Data::NumberToString(message.fromId));
|
||||
}
|
||||
};
|
||||
const auto pushReplyToMsgId = [&](
|
||||
|
@ -640,6 +641,7 @@ Result JsonWriter::writePersonal(const Data::PersonalInfo &data) {
|
|||
return _output->writeBlock(
|
||||
prepareObjectItemStart("personal_information")
|
||||
+ SerializeObject(_context, {
|
||||
{ "user_id", Data::NumberToString(data.user.id) },
|
||||
{ "first_name", SerializeString(info.firstName) },
|
||||
{ "last_name", SerializeString(info.lastName) },
|
||||
{
|
||||
|
@ -745,6 +747,7 @@ Result JsonWriter::writeSavedContacts(const Data::ContactsList &data) {
|
|||
}));
|
||||
} else {
|
||||
block.append(SerializeObject(_context, {
|
||||
{ "user_id", Data::NumberToString(contact.userId) },
|
||||
{ "first_name", SerializeString(contact.firstName) },
|
||||
{ "last_name", SerializeString(contact.lastName) },
|
||||
{
|
||||
|
@ -789,6 +792,7 @@ Result JsonWriter::writeFrequentContacts(const Data::ContactsList &data) {
|
|||
}();
|
||||
block.append(prepareArrayItemStart());
|
||||
block.append(SerializeObject(_context, {
|
||||
{ "id", Data::NumberToString(top.peer.id()) },
|
||||
{ "category", SerializeString(category) },
|
||||
{ "type", SerializeString(type) },
|
||||
{ "name", StringAllowNull(top.peer.name()) },
|
||||
|
@ -981,6 +985,8 @@ Result JsonWriter::writeDialogStart(const Data::DialogInfo &data) {
|
|||
}
|
||||
block.append(prepareObjectItemStart("type")
|
||||
+ StringAllowNull(TypeString(data.type)));
|
||||
block.append(prepareObjectItemStart("id")
|
||||
+ Data::NumberToString(data.peerId));
|
||||
block.append(prepareObjectItemStart("messages"));
|
||||
block.append(pushNesting(Context::kArray));
|
||||
return _output->writeBlock(block);
|
||||
|
|
Loading…
Add table
Reference in a new issue