单次session内重复添加同一好友会有提示,重新登陆后添加相同好友却提示发送成功
This commit is contained in:
parent
a1d97a1ab6
commit
2ae819376f
@ -332,8 +332,12 @@ func (p *Player) FriendListBackData() {
|
||||
fl = append(fl, ps)
|
||||
}
|
||||
}
|
||||
now := GoUtil.Now()
|
||||
ReqFriendList := make([]int64, 0, len(FriendMod.SendApply))
|
||||
for k := range FriendMod.SendApply {
|
||||
for k, v := range FriendMod.SendApply {
|
||||
if now-v > oneday {
|
||||
continue
|
||||
}
|
||||
ReqFriendList = append(ReqFriendList, int64(k))
|
||||
}
|
||||
p.PushClientRes(&proto.ResFriendList{
|
||||
|
||||
@ -133,7 +133,7 @@ func ReqApplyFriend(player *Player, buf []byte) error {
|
||||
}
|
||||
// 对于任何玩家而言,向自己在24小时内已从任意途径发送过好友申请的玩家再次发送好友申请时,该次申请不会被发出
|
||||
sendApplyTime := FriendMod.GetSendApplyTime(Uid)
|
||||
if sendApplyTime != 0 && GoUtil.Now()-sendApplyTime < 86400 {
|
||||
if sendApplyTime != 0 && GoUtil.Now()-sendApplyTime < oneday {
|
||||
player.PushClientRes(&msg.ResApplyFriend{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Uid: req.Uid,
|
||||
@ -141,6 +141,7 @@ func ReqApplyFriend(player *Player, buf []byte) error {
|
||||
})
|
||||
return fmt.Errorf("already applied")
|
||||
}
|
||||
FriendMod.AddSendApply(Uid)
|
||||
now := GoUtil.Now()
|
||||
if req.Type == 1 {
|
||||
Items, err := FriendMod.GetSponsorReward()
|
||||
|
||||
@ -3,7 +3,10 @@ package test
|
||||
import (
|
||||
"fmt"
|
||||
"server/game"
|
||||
"server/msg"
|
||||
"testing"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func TestFriendInit(t *testing.T) {
|
||||
@ -31,3 +34,15 @@ func TestFriendRecommendList(t *testing.T) {
|
||||
l1 := game.GetRecommendPlayer(p1, 3)
|
||||
fmt.Printf("Recommend List: %v\n", l1)
|
||||
}
|
||||
|
||||
func TestReqApplyFriend(t *testing.T) {
|
||||
p1 := new(game.Player)
|
||||
p1.InitPlayer("3625212")
|
||||
req := &msg.ReqApplyFriend{
|
||||
Uid: 100002,
|
||||
Type: 0,
|
||||
}
|
||||
buf, _ := proto.Marshal(req)
|
||||
game.ReqApplyFriend(p1, buf)
|
||||
p1.FriendListBackData()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user