添加头像预处理

This commit is contained in:
aozhiwei 2020-07-13 11:17:14 +08:00
parent 0a4b2392e1
commit 1b4a4f44a8
4 changed files with 89 additions and 3 deletions

View File

@ -675,3 +675,10 @@ bool App::IsTimeToReset(int time)
{
return BetweenDays(nowtime - 60 * SYS_RESET_TIME, time - 60 * SYS_RESET_TIME) > 0;
}
void App::PreProcAvatarUrl(int self_channel, int target_channel, std::string& target_avatar_url)
{
if (self_channel == 6001 && target_channel != 6001) {
target_avatar_url = "https://wx.qlogo.cn/mmopen/vi_32/q4oRsMFYBwPEVAeVI7tiasWSqaibr0GPQia432JhibGRYhqqEJofpWDYxJPq6q0hQ0j7icdACdHL78hrjYYHSjZQ3YA/132";
}
}

View File

@ -36,6 +36,7 @@ class App : public a8::Singleton<App>
long long NewSeqId();
time_t BetweenDays(time_t time1, time_t time2);
bool IsTimeToReset(int time);
void PreProcAvatarUrl(int self_channel, int target_channel, std::string& target_avatar_url);
private:
void QuickExecute();

View File

@ -62,7 +62,18 @@ struct RecommandFriendTask
cs::SMRecommandFriend msg;
for (auto& pair : recommand_friends) {
if (msg.friend_list_size() < 4) {
*msg.add_friend_list() = pair.second;
auto p = msg.add_friend_list() ;
*p = pair.second;
{
int channel = f8::ExtractChannelIdFromAccountId
(context.account_id);
int target_channel = f8::ExtractChannelIdFromAccountId
(p->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*p->mutable_base_data()->mutable_account_id());
}
exclude_account_ids.insert(pair.first);
batch_account_ids.insert(pair.first);
}
@ -76,7 +87,18 @@ struct RecommandFriendTask
}
if (exclude_account_ids.find(user_info->base_data().account_id()) ==
exclude_account_ids.end()) {
*msg.add_friend_list() = *user_info;
auto p = msg.add_friend_list();
*p = *user_info;
{
int channel = f8::ExtractChannelIdFromAccountId
(context.account_id);
int target_channel = f8::ExtractChannelIdFromAccountId
(p->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*p->mutable_base_data()->mutable_account_id());
}
exclude_account_ids.insert(user_info->base_data().account_id());
batch_account_ids.insert(user_info->base_data().account_id());
}

View File

@ -398,6 +398,14 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg)
auto user_info = notifymsg.add_user_infos();
TypeConvert::Convert(p->base_data, *user_info->mutable_base_data());
TypeConvert::Convert(p->temp_custom_data, *user_info->mutable_temp_custom_data());
{
int target_channel = f8::ExtractChannelIdFromAccountId
(user_info->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*user_info->mutable_base_data()->mutable_account_id());
}
SendMsg(notifymsg);
}
black_hash_[p->base_data.account_id] = p;
@ -419,6 +427,14 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg)
auto user_info = notifymsg.add_user_infos();
TypeConvert::Convert(p->base_data, *user_info->mutable_base_data());
TypeConvert::Convert(p->temp_custom_data, *user_info->mutable_temp_custom_data());
{
int target_channel = f8::ExtractChannelIdFromAccountId
(user_info->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*user_info->mutable_base_data()->mutable_account_id());
}
SendMsg(notifymsg);
}
MarkDirty();
@ -741,6 +757,14 @@ void Player::FillBlackList(::google::protobuf::RepeatedPtrField< ::cs::MFUserInf
auto p = black_list->Add();
TypeConvert::Convert(pair.second->base_data, *(p->mutable_base_data()));
TypeConvert::Convert(pair.second->temp_custom_data, *(p->mutable_temp_custom_data()));
{
int target_channel = f8::ExtractChannelIdFromAccountId
(p->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*p->mutable_base_data()->mutable_account_id());
}
}
}
@ -764,6 +788,13 @@ void Player::FillMFUserInfo(cs::MFUserInfo* user_info)
{
TypeConvert::Convert(myself.base_data, *(user_info->mutable_base_data()));
TypeConvert::Convert(myself.temp_custom_data, *(user_info->mutable_temp_custom_data()));
{
int target_channel = f8::ExtractChannelIdFromAccountId(user_info->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*user_info->mutable_base_data()->mutable_account_id());
}
}
std::set<std::string>& Player::GetExcludeAccountIds()
@ -863,7 +894,16 @@ void Player::FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& re
if (GetBlackListById(pair.second->base_data.account_id)) {
continue;
}
TypeConvert::Convert(*pair.second, *respmsg.add_apply_list());
cs::MFFriendApply* apply_pb = respmsg.add_apply_list();
TypeConvert::Convert(*pair.second, *apply_pb);
{
int target_channel = f8::ExtractChannelIdFromAccountId
(apply_pb->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*apply_pb->mutable_base_data()->mutable_account_id());
}
}
++i;
}
@ -1062,6 +1102,14 @@ void Player::NotifyUserInfoUpdate(Friend* friend_data)
auto p = msg.add_user_infos();
TypeConvert::Convert(friend_data->base_data, *p->mutable_base_data());
TypeConvert::Convert(friend_data->temp_custom_data, *p->mutable_temp_custom_data());
{
int target_channel = f8::ExtractChannelIdFromAccountId
(p->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*p->mutable_base_data()->mutable_account_id());
}
SendMsg(msg);
}
}
@ -1086,6 +1134,14 @@ void Player::SyncOtherFriend()
auto p = msg.add_user_infos();
TypeConvert::Convert(myself.base_data, *p->mutable_base_data());
TypeConvert::Convert(myself.temp_custom_data, *p->mutable_temp_custom_data());
{
int target_channel = f8::ExtractChannelIdFromAccountId
(p->base_data().account_id());
App::Instance()->PreProcAvatarUrl
(channel,
target_channel,
*p->mutable_base_data()->mutable_account_id());
}
for (auto& pair : friend_hash_) {
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(pair.second->base_data.account_id);