diff --git a/server/imserver_new/friend/friendmgr.go b/server/imserver_new/friend/friendmgr.go index 11d0d934..cf85e5ed 100644 --- a/server/imserver_new/friend/friendmgr.go +++ b/server/imserver_new/friend/friendmgr.go @@ -278,10 +278,32 @@ func (this *friendMgr) AsyncRejectApply(senderId string, targetId string, cb fun } func (this *friendMgr) AsynDeleteFriend(senderId string, targetId string, cb func(int32, string)) { - if this.IsFriend(senderId, targetId) { + if !this.IsFriend(senderId, targetId) || + senderId == targetId { cb(0, "") return } + accountId1, accountId2 := this.sortAccounts(senderId, targetId) + f5.GetJsStyleDb().Update( + constant.FRIEND_DB, + "t_friend_relationship", + [][]string{ + {"deleted", q5.ToString(1)}, + {"del_time", q5.ToString(f5.GetApp().GetNowSeconds())}, + }, + [][]string{ + {"account_id1", accountId1}, + {"account_id2", accountId2}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + if err != nil { + cb(1, "") + return + } + this.removeFriendShip(accountId1, accountId2) + cb(0, "") + + }) } func (this *friendMgr) AsyncAddBlack(senderId string, targetId string, cb func(int32, string)) { @@ -311,6 +333,21 @@ func (this *friendMgr) addFriendShip(accountId1 string, accountId2 string, addTi } } +func (this *friendMgr) removeFriendShip(accountId1 string, accountId2 string) { + { + friends := this.getFriends(accountId1) + if friends != nil { + delete(*friends, accountId2) + } + } + { + friends := this.getFriends(accountId2) + if friends != nil { + delete(*friends, accountId1) + } + } +} + func (this *friendMgr) addBlackList(accountId string, blockId string, addTime int32) { { blacks := this.getBlacks(accountId)