diff --git a/server/imserver/player.cc b/server/imserver/player.cc index 758ee9c..24500df 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -363,12 +363,12 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg) ShowErrorMsg("添加失败,黑名单已满"); return; } - Friend* p = GetFriendById(msg.account_id()); + Friend* p = GetFriendById(msg.user_info().base_data().account_id()); if (p) { - if (!GetBlackListById(msg.account_id())) { + if (!GetBlackListById(msg.user_info().base_data().account_id())) { { cs::SMDeleteFriendNotify notifymsg; - notifymsg.add_user_list(msg.account_id()); + notifymsg.add_user_list(msg.user_info().base_data().account_id()); SendMsg(notifymsg); } { @@ -384,7 +384,19 @@ void Player::_CMFriendAddBlack(f8::MsgHdr& hdr, const cs::CMFriendAddBlack& msg) } ShowErrorMsg("成功添加到黑名单"); } else { - ShowErrorMsg("对方不是你的好友"); + if (msg.user_info().base_data().account_id() == AccountId()) { + return; + } + p = new Friend(); + TypeConvert::Convert(msg.user_info().base_data(), p->base_data); + AddBlackList(p); + { + cs::SMAddBlackListNotify notifymsg; + 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()); + SendMsg(notifymsg); + } } } @@ -919,17 +931,15 @@ void Player::AddBlackList(Friend* friendobj) if (friendobj->base_data.account_id == AccountId()) { return; } - if (!GetFriendById(friendobj->base_data.account_id)) { - INIT_LIST_HEAD(&friendobj->watch_node); - friendobj->crc32_code = a8::openssl::Crc32 - ( - (unsigned char*)friendobj->base_data.account_id.data(), - friendobj->base_data.account_id.size() - ); - friendobj->hum = this; - black_hash_[friendobj->base_data.account_id] = friendobj; - PlayerMgr::Instance()->WatchPlayer(friendobj); - } + INIT_LIST_HEAD(&friendobj->watch_node); + friendobj->crc32_code = a8::openssl::Crc32 + ( + (unsigned char*)friendobj->base_data.account_id.data(), + friendobj->base_data.account_id.size() + ); + friendobj->hum = this; + black_hash_[friendobj->base_data.account_id] = friendobj; + PlayerMgr::Instance()->WatchPlayer(friendobj); } void Player::RemoveFriend(const std::string& account_id, bool need_sync) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index afb5038..05da98b 100644 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -198,7 +198,7 @@ message SMFriendBlackList //添加黑名单 message CMFriendAddBlack { - optional string account_id = 1; //好友id + optional MFUserInfo user_info = 1; //好友信息 } //添加黑名单回复 message SMFriendAddBlack