Update API scheme on layer 148: Usernames.

This commit is contained in:
John Preston 2022-10-14 17:54:31 +04:00
parent 6997e165c6
commit 16e189a2ce
3 changed files with 27 additions and 16 deletions

View File

@ -301,7 +301,7 @@ updateUserTyping#c01e857f user_id:long action:SendMessageAction = Update;
updateChatUserTyping#83487af0 chat_id:long from_id:Peer action:SendMessageAction = Update;
updateChatParticipants#7761198 participants:ChatParticipants = Update;
updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update;
updateUserName#c3f202e0 user_id:long first_name:string last_name:string username:string = Update;
updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector<Username> = Update;
updateUserPhoto#f227868c user_id:long date:int photo:UserProfilePhoto previous:Bool = Update;
updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update;
updateEncryptedChatTyping#1710f156 chat_id:int = Update;
@ -957,6 +957,7 @@ channelAdminLogEventActionParticipantJoinByRequest#afb6144a invite:ExportedChatI
channelAdminLogEventActionToggleNoForwards#cb2ac766 new_value:Bool = ChannelAdminLogEventAction;
channelAdminLogEventActionSendMessage#278f2868 message:Message = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeAvailableReactions#be4e0ef8 prev_value:ChatReactions new_value:ChatReactions = ChannelAdminLogEventAction;
channelAdminLogEventActionChangeUsernames#f04fb3a9 prev_value:Vector<string> new_value:Vector<string> = ChannelAdminLogEventAction;
channelAdminLogEvent#1fad68cd id:long date:int user_id:long action:ChannelAdminLogEventAction = ChannelAdminLogEvent;

View File

@ -1872,21 +1872,22 @@ void Updates::feedUpdate(const MTPUpdate &update) {
} break;
case mtpc_updateUserName: {
auto &d = update.c_updateUserName();
if (auto user = session().data().userLoaded(d.vuser_id())) {
if (!user->isContact()) {
user->setName(
TextUtilities::SingleLine(qs(d.vfirst_name())),
TextUtilities::SingleLine(qs(d.vlast_name())),
user->nameOrPhone,
TextUtilities::SingleLine(qs(d.vusername())));
} else {
user->setName(
TextUtilities::SingleLine(user->firstName),
TextUtilities::SingleLine(user->lastName),
user->nameOrPhone,
TextUtilities::SingleLine(qs(d.vusername())));
}
const auto &d = update.c_updateUserName();
if (const auto user = session().data().userLoaded(d.vuser_id())) {
const auto contact = user->isContact();
const auto first = contact
? user->firstName
: qs(d.vfirst_name());
const auto last = contact ? user->lastName : qs(d.vlast_name());
// #TODO usernames
const auto username = d.vusernames().v.isEmpty()
? QString()
: qs(d.vusernames().v.front().data().vusername());
user->setName(
TextUtilities::SingleLine(first),
TextUtilities::SingleLine(last),
user->nameOrPhone,
TextUtilities::SingleLine(username));
}
} break;

View File

@ -697,6 +697,7 @@ void GenerateItems(
using LogNoForwards = MTPDchannelAdminLogEventActionToggleNoForwards;
using LogActionSendMessage = MTPDchannelAdminLogEventActionSendMessage;
using LogEventActionChangeAvailableReactions = MTPDchannelAdminLogEventActionChangeAvailableReactions;
using LogEventActionChangeUsernames = MTPDchannelAdminLogEventActionChangeUsernames;
const auto session = &history->session();
const auto id = event.vid().v;
@ -1513,6 +1514,12 @@ void GenerateItems(
addSimpleServiceMessage(text);
};
const auto createChangeUsernames = [&](
const LogEventActionChangeUsernames &data) {
// #TODO usernames
addSimpleServiceMessage({ "changed usernames" });
};
action.match([&](const LogTitle &data) {
createChangeTitle(data);
}, [&](const LogAbout &data) {
@ -1585,6 +1592,8 @@ void GenerateItems(
createSendMessage(data);
}, [&](const LogEventActionChangeAvailableReactions &data) {
createChangeAvailableReactions(data);
}, [&](const LogEventActionChangeUsernames &data) {
createChangeUsernames(data);
});
}