1
This commit is contained in:
parent
f88d6b5910
commit
4063317164
@ -141,6 +141,17 @@ func (this *friendMgr) getFriends(accountId string) *map[string]int32 {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *friendMgr) IsBlack(senderId string, targetId string) bool {
|
||||||
|
myBlacks := this.getBlacks(senderId)
|
||||||
|
if myBlacks != nil {
|
||||||
|
if _, ok := (*myBlacks)[targetId]; ok {
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *friendMgr) getBlacks(accountId string) *map[string]int32 {
|
func (this *friendMgr) getBlacks(accountId string) *map[string]int32 {
|
||||||
if blacks, ok := this.blackHash[accountId]; ok {
|
if blacks, ok := this.blackHash[accountId]; ok {
|
||||||
return &blacks
|
return &blacks
|
||||||
@ -307,11 +318,64 @@ func (this *friendMgr) AsynDeleteFriend(senderId string, targetId string, cb fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *friendMgr) AsyncAddBlack(senderId string, targetId string, cb func(int32, string)) {
|
func (this *friendMgr) AsyncAddBlack(senderId string, targetId string, cb func(int32, string)) {
|
||||||
|
if this.IsBlack(senderId, targetId) {
|
||||||
|
cb(0, "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
nowTime := f5.GetApp().GetNowSeconds()
|
||||||
|
f5.GetJsStyleDb().Upsert(
|
||||||
|
constant.FRIEND_DB,
|
||||||
|
"t_friend_blacklist",
|
||||||
|
[][]string{
|
||||||
|
{"sender_id", senderId},
|
||||||
|
{"block_id", targetId},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"deleted", q5.ToString(0)},
|
||||||
|
{"add_time", q5.ToString(nowTime)},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"sender_id", senderId},
|
||||||
|
{"block_id", targetId},
|
||||||
|
{"deleted", q5.ToString(0)},
|
||||||
|
{"add_time", q5.ToString(nowTime)},
|
||||||
|
{"createtime", q5.ToString(nowTime)},
|
||||||
|
{"modifytime", q5.ToString(nowTime)},
|
||||||
|
},
|
||||||
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
if err != nil {
|
||||||
|
cb(1, "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.addBlackList(senderId, targetId, int32(nowTime))
|
||||||
|
cb(0, "")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *friendMgr) AsyncRemoveBlack(senderId string, targetId string, cb func(int32, string)) {
|
func (this *friendMgr) AsyncRemoveBlack(senderId string, targetId string, cb func(int32, string)) {
|
||||||
|
if !this.IsBlack(senderId, targetId) {
|
||||||
|
cb(0, "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f5.GetJsStyleDb().Update(
|
||||||
|
constant.FRIEND_DB,
|
||||||
|
"t_friend_blacklist",
|
||||||
|
[][]string{
|
||||||
|
{"deleted", q5.ToString(1)},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"account_id", senderId},
|
||||||
|
{"block_id", targetId},
|
||||||
|
},
|
||||||
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
if err != nil {
|
||||||
|
cb(1, "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.removeBlackList(senderId, targetId)
|
||||||
|
cb(0, "")
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *friendMgr) addFriendShip(accountId1 string, accountId2 string, addTime int32) {
|
func (this *friendMgr) addFriendShip(accountId1 string, accountId2 string, addTime int32) {
|
||||||
@ -359,6 +423,15 @@ func (this *friendMgr) addBlackList(accountId string, blockId string, addTime in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *friendMgr) removeBlackList(accountId string, blockId string) {
|
||||||
|
{
|
||||||
|
blacks := this.getBlacks(accountId)
|
||||||
|
if blacks != nil {
|
||||||
|
delete(*blacks, blockId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *friendMgr) sortAccounts(senderId string, targetId string) (string, string) {
|
func (this *friendMgr) sortAccounts(senderId string, targetId string) (string, string) {
|
||||||
if senderId < targetId {
|
if senderId < targetId {
|
||||||
return senderId, targetId
|
return senderId, targetId
|
||||||
|
Loading…
x
Reference in New Issue
Block a user