Ver código fonte

update

master
DengBiao 1 ano atrás
pai
commit
73ac2c5d80
3 arquivos alterados com 11 adições e 6 exclusões
  1. +1
    -1
      internal/business/api/business_ext.go
  2. +1
    -1
      internal/business/comm/md/app_redis_key.go
  3. +9
    -4
      internal/logic/domain/friend/friend_service.go

+ 1
- 1
internal/business/api/business_ext.go Ver arquivo

@@ -66,7 +66,7 @@ func (s *BusinessExtServer) IsFriends(ctx context.Context, req *pb.IsFriendsReq)
return nil, err
}
var isFriend = int64(1)
if friend == nil {
if friend == nil || friend.Status == friend2.FriendStatusApply {
isFriend = 2
}



+ 1
- 1
internal/business/comm/md/app_redis_key.go Ver arquivo

@@ -4,5 +4,5 @@ package md
const (
AppCfgCacheKey = "%s:gim_cfg_cache:%s" // 占位符: masterId, key的第一个字母
AppUserPushForJgCacheKey = "%s:gim_user_push_for_jg_cache:%s" // 占位符: masterId, key的第一个字母
CfgCacheTime = 86400
CfgCacheTime = 0.5 * 60 * 60
)

+ 9
- 4
internal/logic/domain/friend/friend_service.go Ver arquivo

@@ -6,6 +6,7 @@ import (
"gim/internal/business/comm/utils"
"gim/internal/logic/domain/message/repo"
"gim/internal/logic/proxy"
"gim/pkg/db"
"gim/pkg/gerrors"
"gim/pkg/grpclib"
"gim/pkg/pb"
@@ -66,13 +67,20 @@ func (*friendService) DeleteFriend(ctx context.Context, userId, friendId int64)

// AddFriend 添加好友
func (*friendService) AddFriend(ctx context.Context, userId, friendId int64, remarks, description string) error {
masterId, _ := grpclib.GetCtxMasterId(ctx)
isAutoAddFriends := svc.SysCfgGet(masterId, "is_auto_add_friends")

friend, err := FriendRepo.Get(userId, friendId)
if err != nil {
return err
}
if friend != nil {
if friend.Status == FriendStatusApply {
return nil
if isAutoAddFriends != "1" {
return nil
}
//TODO::防止第一次加好友失败
db.DB.Where("user_id = ? and friend_id = ?", userId, friendId).Delete(&friend)
}
if friend.Status == FriendStatusAgree {
return gerrors.ErrAlreadyIsFriend
@@ -108,9 +116,6 @@ func (*friendService) AddFriend(ctx context.Context, userId, friendId int64, rem
}

//TODO::判断是否需要`自动添加好友`
masterId, _ := grpclib.GetCtxMasterId(ctx)
isAutoAddFriends := svc.SysCfgGet(masterId, "is_auto_add_friends")

//if isAutoAddFriends == "1" && resp.User.IsAutoAddedFriends == 1 {
if isAutoAddFriends == "1" {
respFriend, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: friendId})


Carregando…
Cancelar
Salvar