mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Added ability to export peer ids from contact list.
This commit is contained in:
parent
f20e393d77
commit
e79be73025
3 changed files with 48 additions and 5 deletions
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "export/output/export_output_file.h"
|
||||
#include "mtproto/mtproto_response.h"
|
||||
#include "base/bytes.h"
|
||||
#include "base/options.h"
|
||||
#include "base/random.h"
|
||||
#include <set>
|
||||
#include <deque>
|
||||
|
@ -1069,7 +1070,35 @@ void ApiWrap::requestContacts(FnMut<void(Data::ContactsList&&)> done) {
|
|||
mainRequest(MTPcontacts_GetSaved(
|
||||
)).done([=](const MTPVector<MTPSavedContact> &result) {
|
||||
_contactsProcess->result = Data::ParseContactsList(result);
|
||||
requestTopPeersSlice();
|
||||
|
||||
const auto resolve = [=](int index, const auto &resolveNext) -> void {
|
||||
if (index == _contactsProcess->result.list.size()) {
|
||||
return requestTopPeersSlice();
|
||||
}
|
||||
const auto &contact = _contactsProcess->result.list[index];
|
||||
mainRequest(MTPcontacts_ResolvePhone(
|
||||
MTP_string(qs(contact.phoneNumber))
|
||||
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||
auto &contact = _contactsProcess->result.list[index];
|
||||
contact.userId = result.data().vpeer().match([&](
|
||||
const MTPDpeerUser &user) {
|
||||
return UserId(user.vuser_id());
|
||||
}, [](const auto &) {
|
||||
return UserId();
|
||||
});
|
||||
resolveNext(index + 1, resolveNext);
|
||||
}).fail([=](const MTP::Error &) {
|
||||
resolveNext(index + 1, resolveNext);
|
||||
return true;
|
||||
}).send();
|
||||
};
|
||||
|
||||
if (base::options::lookup<bool>("show-peer-id-below-about").value()) {
|
||||
resolve(0, resolve);
|
||||
} else {
|
||||
requestTopPeersSlice();
|
||||
}
|
||||
|
||||
}).send();
|
||||
}
|
||||
|
||||
|
|
|
@ -357,6 +357,7 @@ struct UserpicData {
|
|||
QString largeLink;
|
||||
QByteArray firstName;
|
||||
QByteArray lastName;
|
||||
QByteArray tooltip;
|
||||
};
|
||||
|
||||
struct StoryData {
|
||||
|
@ -743,9 +744,17 @@ QByteArray HtmlWriter::Wrap::pushUserpic(const UserpicData &userpic) {
|
|||
},
|
||||
{ "style", sizeStyle }
|
||||
}));
|
||||
result.append(pushDiv(
|
||||
"initials",
|
||||
"line-height: " + size));
|
||||
if (userpic.tooltip.isEmpty()) {
|
||||
result.append(pushDiv(
|
||||
"initials",
|
||||
"line-height: " + size));
|
||||
} else {
|
||||
result.append(pushTag("div", {
|
||||
{ "class", "initials" },
|
||||
{ "style", "line-height: " + size },
|
||||
{ "title", userpic.tooltip },
|
||||
}));
|
||||
}
|
||||
auto character = [](const QByteArray &from) {
|
||||
const auto utf = QString::fromUtf8(from).trimmed();
|
||||
return utf.isEmpty()
|
||||
|
@ -2493,6 +2502,10 @@ Result HtmlWriter::writeSavedContacts(const Data::ContactsList &data) {
|
|||
};
|
||||
userpic.firstName = contact.firstName;
|
||||
userpic.lastName = contact.lastName;
|
||||
if (contact.userId) {
|
||||
const auto raw = contact.userId.bare & PeerId::kChatTypeMask;
|
||||
userpic.tooltip = (u"ID: "_q + QString::number(raw)).toUtf8();
|
||||
}
|
||||
block.append(file->pushListEntry(
|
||||
userpic,
|
||||
ComposeName(userpic, "Deleted Account"),
|
||||
|
|
|
@ -74,7 +74,8 @@ namespace {
|
|||
base::options::toggle ShowPeerIdBelowAbout({
|
||||
.id = kOptionShowPeerIdBelowAbout,
|
||||
.name = "Show Peer IDs in Profile",
|
||||
.description = "Show peer IDs from API below their Bio / Description.",
|
||||
.description = "Show peer IDs from API below their Bio / Description."
|
||||
" Add contact IDs to exported data.",
|
||||
});
|
||||
|
||||
[[nodiscard]] rpl::producer<TextWithEntities> UsernamesSubtext(
|
||||
|
|
Loading…
Add table
Reference in a new issue