diff --git a/server/imserver/app.cc b/server/imserver/app.cc index 37b7736..7b43173 100644 --- a/server/imserver/app.cc +++ b/server/imserver/app.cc @@ -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"; + } +} diff --git a/server/imserver/app.h b/server/imserver/app.h index 7d2b1bf..3917ff1 100644 --- a/server/imserver/app.h +++ b/server/imserver/app.h @@ -36,6 +36,7 @@ class App : public a8::Singleton 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(); diff --git a/server/imserver/asynctaskmgr.cc b/server/imserver/asynctaskmgr.cc index 84e306d..7016714 100644 --- a/server/imserver/asynctaskmgr.cc +++ b/server/imserver/asynctaskmgr.cc @@ -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()); } diff --git a/server/imserver/player.cc b/server/imserver/player.cc index eff560e..f41c425 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -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& 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);