This commit is contained in:
aozhiwei 2020-07-01 13:07:01 +08:00
parent 16e36e091f
commit 40bdddabf2
2 changed files with 26 additions and 16 deletions

View File

@ -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)

View File

@ -198,7 +198,7 @@ message SMFriendBlackList
//
message CMFriendAddBlack
{
optional string account_id = 1; //id
optional MFUserInfo user_info = 1; //
}
//
message SMFriendAddBlack