(matrix) Fetch own displayname, use correct user ID

This commit is contained in:
Jaidyn Ann 2021-09-04 21:17:25 -05:00
parent 604082466e
commit 8456e00bd8

View File

@ -129,16 +129,25 @@ MatrixApp::Connect()
void void
MatrixApp::StartLoop() MatrixApp::StartLoop()
{ {
client->get_profile(client->user_id().to_string(),
[this](const mtx::responses::Profile &res, mtx::http::RequestErr err)
{
if (err) {
print_error(err, "Failed getting own info after login…");
StartLoop();
snooze(1000000);
return;
}
BMessage ready(IM_MESSAGE); BMessage ready(IM_MESSAGE);
ready.AddInt32("im_what", IM_PROTOCOL_READY); ready.AddInt32("im_what", IM_PROTOCOL_READY);
SendMessage(ready); SendMessage(ready);
BString mxId("@");
mxId << fUser << ":" << fServer;
BMessage init(IM_MESSAGE); BMessage init(IM_MESSAGE);
init.AddInt32("im_what", IM_OWN_CONTACT_INFO); init.AddInt32("im_what", IM_OWN_CONTACT_INFO);
init.AddString("user_id", mxId); init.AddString("user_id", client->user_id().to_string().c_str());
init.AddString("user_name", res.display_name.c_str());
SendMessage(init); SendMessage(init);
});
BMessage status(IM_MESSAGE); BMessage status(IM_MESSAGE);
status.AddInt32("im_what", IM_OWN_STATUS_SET); status.AddInt32("im_what", IM_OWN_STATUS_SET);