This commit is contained in:
aozhiwei 2024-03-30 11:10:50 +08:00
parent 07bf6d35ff
commit f88d6b5910

View File

@ -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)) { 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, "") cb(0, "")
return 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)) { 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) { func (this *friendMgr) addBlackList(accountId string, blockId string, addTime int32) {
{ {
blacks := this.getBlacks(accountId) blacks := this.getBlacks(accountId)