|
|
@ -45,6 +45,7 @@ type friendServer struct {
|
|
|
|
blackDatabase controller.BlackDatabase
|
|
|
|
blackDatabase controller.BlackDatabase
|
|
|
|
userRpcClient *rpcclient.UserRpcClient
|
|
|
|
userRpcClient *rpcclient.UserRpcClient
|
|
|
|
notificationSender *notification.FriendNotificationSender
|
|
|
|
notificationSender *notification.FriendNotificationSender
|
|
|
|
|
|
|
|
conversationRpcClient rpcclient.ConversationRpcClient
|
|
|
|
RegisterCenter registry.SvcDiscoveryRegistry
|
|
|
|
RegisterCenter registry.SvcDiscoveryRegistry
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -82,6 +83,7 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
|
|
|
userRpcClient: &userRpcClient,
|
|
|
|
userRpcClient: &userRpcClient,
|
|
|
|
notificationSender: notificationSender,
|
|
|
|
notificationSender: notificationSender,
|
|
|
|
RegisterCenter: client,
|
|
|
|
RegisterCenter: client,
|
|
|
|
|
|
|
|
conversationRpcClient: rpcclient.NewConversationRpcClient(client),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -131,17 +133,22 @@ func (s *friendServer) ImportFriends(
|
|
|
|
if _, err := s.userRpcClient.GetUsersInfo(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...)); err != nil {
|
|
|
|
if _, err := s.userRpcClient.GetUsersInfo(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...)); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if utils.Contain(req.OwnerUserID, req.FriendUserIDs...) {
|
|
|
|
if utils.Contain(req.OwnerUserID, req.FriendUserIDs...) {
|
|
|
|
return nil, errs.ErrCanNotAddYourself.Wrap()
|
|
|
|
return nil, errs.ErrCanNotAddYourself.Wrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if utils.Duplicate(req.FriendUserIDs) {
|
|
|
|
if utils.Duplicate(req.FriendUserIDs) {
|
|
|
|
return nil, errs.ErrArgs.Wrap("friend userID repeated")
|
|
|
|
return nil, errs.ErrArgs.Wrap("friend userID repeated")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := s.friendDatabase.BecomeFriends(ctx, req.OwnerUserID, req.FriendUserIDs, constant.BecomeFriendByImport); err != nil {
|
|
|
|
if err := s.friendDatabase.BecomeFriends(ctx, req.OwnerUserID, req.FriendUserIDs, constant.BecomeFriendByImport); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, userID := range req.FriendUserIDs {
|
|
|
|
|
|
|
|
s.notificationSender.FriendApplicationAgreedNotification(ctx, &pbfriend.RespondFriendApplyReq{
|
|
|
|
|
|
|
|
FromUserID: req.OwnerUserID,
|
|
|
|
|
|
|
|
ToUserID: userID,
|
|
|
|
|
|
|
|
HandleResult: constant.FriendResponseAgree,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
return &pbfriend.ImportFriendResp{}, nil
|
|
|
|
return &pbfriend.ImportFriendResp{}, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|