Set correct username to crash annotations.

This commit is contained in:
John Preston 2020-06-30 20:41:25 +04:00
parent 5ea5d3c60d
commit 9fb12b6093
2 changed files with 18 additions and 3 deletions

View file

@ -462,9 +462,6 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
: QString())
: result->nameOrPhone;
if (!minimal && data.is_self() && uname != result->username) {
CrashReports::SetAnnotation("Username", uname);
}
result->setName(fname, lname, pname, uname);
if (const auto photo = data.vphoto()) {
result->setPhoto(*photo);

View file

@ -9,9 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "core/shortcuts.h"
#include "core/crash_reports.h"
#include "main/main_account.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_changes.h"
#include "data/data_user.h"
#include "mtproto/mtproto_config.h"
#include "mtproto/mtproto_dc_options.h"
#include "storage/storage_domain.h"
@ -31,6 +34,21 @@ Domain::Domain(const QString &dataName)
Local::rewriteSettingsIfNeeded();
Core::App().notifications().createManager();
}, _lifetime);
_active.changes(
) | rpl::map([](Main::Account *account) {
return account ? account->sessionValue() : rpl::never<Session*>();
}) | rpl::flatten_latest(
) | rpl::map([](Main::Session *session) {
return session
? session->changes().peerFlagsValue(
session->user(),
Data::PeerUpdate::Flag::Username)
: rpl::never<Data::PeerUpdate>();
}) | rpl::flatten_latest(
) | rpl::start_with_next([](const Data::PeerUpdate &update) {
CrashReports::SetAnnotation("Username", update.peer->userName());
}, _lifetime);
}
Domain::~Domain() = default;