mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Refactor code
This commit is contained in:
parent
87f14be30c
commit
a583a31220
@ -68,48 +68,6 @@ func (s *friendServer) Run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////
|
|
||||||
//func (s *friendServer) GetFriendsInfo(ctx context.Context, req *pbFriend.GetFriendsInfoReq) (*pbFriend.GetFriendInfoResp, error) {
|
|
||||||
// return nil, nil
|
|
||||||
//// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
|
||||||
//// var (
|
|
||||||
//// isInBlackList int32
|
|
||||||
//// // isFriend int32
|
|
||||||
//// comment string
|
|
||||||
//// )
|
|
||||||
////
|
|
||||||
//// friendShip, err := imdb.FindFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
|
||||||
//// if err != nil {
|
|
||||||
//// log.NewError(req.CommID.OperationID, "FindFriendRelationshipFromFriend failed ", err.Error())
|
|
||||||
//// return &pbFriend.GetFriendInfoResp{ErrCode: constant.ErrSearchUserInfo.ErrCode, ErrMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
|
||||||
//// // isFriend = constant.FriendFlag
|
|
||||||
//// }
|
|
||||||
//// comment = friendShip.Remark
|
|
||||||
////
|
|
||||||
//// friendUserInfo, err := imdb.FindUserByUID(req.CommID.ToUserID)
|
|
||||||
//// if err != nil {
|
|
||||||
//// log.NewError(req.CommID.OperationID, "FindUserByUID failed ", err.Error())
|
|
||||||
//// return &pbFriend.GetFriendInfoResp{ErrCode: constant.ErrSearchUserInfo.ErrCode, ErrMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// err = imdb.FindRelationshipFromBlackList(req.CommID.FromUserID, req.CommID.ToUserID)
|
|
||||||
//// if err == nil {
|
|
||||||
//// isInBlackList = constant.BlackListFlag
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// resp := pbFriend.GetFriendInfoResp{ErrCode: 0, ErrMsg: "",}
|
|
||||||
////
|
|
||||||
//// utils.CopyStructFields(resp.FriendInfoList, friendUserInfo)
|
|
||||||
//// resp.Data.IsBlack = isInBlackList
|
|
||||||
//// resp.Data.OwnerUserID = req.CommID.FromUserID
|
|
||||||
//// resp.Data.Remark = comment
|
|
||||||
//// resp.Data.CreateTime = friendUserInfo.CreateTime
|
|
||||||
////
|
|
||||||
//// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo ok ", resp)
|
|
||||||
//// return &resp, nil
|
|
||||||
////
|
|
||||||
//}
|
|
||||||
|
|
||||||
func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlacklistReq) (*pbFriend.AddBlacklistResp, error) {
|
func (s *friendServer) AddBlacklist(ctx context.Context, req *pbFriend.AddBlacklistReq) (*pbFriend.AddBlacklistResp, error) {
|
||||||
log.NewInfo(req.CommID.OperationID, "AddBlacklist args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "AddBlacklist args ", req.String())
|
||||||
ok := token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID)
|
ok := token_verify.CheckAccess(req.CommID.OpUserID, req.CommID.FromUserID)
|
||||||
@ -153,7 +111,7 @@ func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq
|
|||||||
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.FriendApplicationAddedNotification(req)
|
chat.FriendApplicationNotification(req)
|
||||||
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
return &pbFriend.AddFriendResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +193,7 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|||||||
log.NewError(req.CommID.OperationID, "GetFriendApplicationByBothUserID failed ", err.Error(), req.CommID.ToUserID, req.CommID.FromUserID)
|
log.NewError(req.CommID.OperationID, "GetFriendApplicationByBothUserID failed ", err.Error(), req.CommID.ToUserID, req.CommID.FromUserID)
|
||||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
friendRequest.HandleResult = req.Flag
|
friendRequest.HandleResult = req.HandleResult
|
||||||
friendRequest.HandleTime = time.Now()
|
friendRequest.HandleTime = time.Now()
|
||||||
//friendRequest.HandleTime.Unix()
|
//friendRequest.HandleTime.Unix()
|
||||||
friendRequest.HandleMsg = req.HandleMsg
|
friendRequest.HandleMsg = req.HandleMsg
|
||||||
@ -247,7 +205,7 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Change the status of the friend request form
|
//Change the status of the friend request form
|
||||||
if req.Flag == constant.FriendFlag {
|
if req.HandleResult == constant.FriendFlag {
|
||||||
//Establish friendship after find friend relationship not exists
|
//Establish friendship after find friend relationship not exists
|
||||||
_, err := imdb.GetFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
_, err := imdb.GetFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -275,8 +233,13 @@ func (s *friendServer) AddFriendResponse(ctx context.Context, req *pbFriend.AddF
|
|||||||
chat.FriendAddedNotification(req.CommID.OperationID, req.CommID.OpUserID, req.CommID.FromUserID, req.CommID.ToUserID)
|
chat.FriendAddedNotification(req.CommID.OperationID, req.CommID.OpUserID, req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if req.HandleResult == constant.FriendResponseAgree {
|
||||||
chat.FriendApplicationProcessedNotification(req)
|
chat.FriendApplicationApprovedNotification(req)
|
||||||
|
} else if req.HandleResult == constant.FriendResponseRefuse {
|
||||||
|
chat.FriendApplicationRejectedNotification(req)
|
||||||
|
} else {
|
||||||
|
log.Error(req.CommID.OperationID, "HandleResult failed ", req.HandleResult)
|
||||||
|
}
|
||||||
log.NewInfo(req.CommID.OperationID, "rpc AddFriendResponse ok")
|
log.NewInfo(req.CommID.OperationID, "rpc AddFriendResponse ok")
|
||||||
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
return &pbFriend.AddFriendResponseResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
@ -345,7 +308,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri
|
|||||||
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
log.NewInfo(req.CommID.OperationID, "rpc SetFriendComment ok")
|
log.NewInfo(req.CommID.OperationID, "rpc SetFriendComment ok")
|
||||||
chat.FriendInfoChangedNotification(req.CommID.OperationID, req.CommID.OpUserID, req.CommID.FromUserID, req.CommID.ToUserID)
|
chat.FriendRemarkSetNotification(req.CommID.OperationID, req.CommID.OpUserID, req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
return &pbFriend.SetFriendRemarkResp{CommonResp: &pbFriend.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,3 +470,45 @@ func (s *friendServer) GetSelfApplyList(ctx context.Context, req *pbFriend.GetSe
|
|||||||
log.NewInfo(req.CommID.OperationID, "rpc GetSelfApplyList ok", pbFriend.GetSelfApplyListResp{FriendRequestList: selfApplyOtherUserList})
|
log.NewInfo(req.CommID.OperationID, "rpc GetSelfApplyList ok", pbFriend.GetSelfApplyListResp{FriendRequestList: selfApplyOtherUserList})
|
||||||
return &pbFriend.GetSelfApplyListResp{FriendRequestList: selfApplyOtherUserList}, nil
|
return &pbFriend.GetSelfApplyListResp{FriendRequestList: selfApplyOtherUserList}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////
|
||||||
|
//func (s *friendServer) GetFriendsInfo(ctx context.Context, req *pbFriend.GetFriendsInfoReq) (*pbFriend.GetFriendInfoResp, error) {
|
||||||
|
// return nil, nil
|
||||||
|
//// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
||||||
|
//// var (
|
||||||
|
//// isInBlackList int32
|
||||||
|
//// // isFriend int32
|
||||||
|
//// comment string
|
||||||
|
//// )
|
||||||
|
////
|
||||||
|
//// friendShip, err := imdb.FindFriendRelationshipFromFriend(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
|
//// if err != nil {
|
||||||
|
//// log.NewError(req.CommID.OperationID, "FindFriendRelationshipFromFriend failed ", err.Error())
|
||||||
|
//// return &pbFriend.GetFriendInfoResp{ErrCode: constant.ErrSearchUserInfo.ErrCode, ErrMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||||
|
//// // isFriend = constant.FriendFlag
|
||||||
|
//// }
|
||||||
|
//// comment = friendShip.Remark
|
||||||
|
////
|
||||||
|
//// friendUserInfo, err := imdb.FindUserByUID(req.CommID.ToUserID)
|
||||||
|
//// if err != nil {
|
||||||
|
//// log.NewError(req.CommID.OperationID, "FindUserByUID failed ", err.Error())
|
||||||
|
//// return &pbFriend.GetFriendInfoResp{ErrCode: constant.ErrSearchUserInfo.ErrCode, ErrMsg: constant.ErrSearchUserInfo.ErrMsg}, nil
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// err = imdb.FindRelationshipFromBlackList(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
|
//// if err == nil {
|
||||||
|
//// isInBlackList = constant.BlackListFlag
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// resp := pbFriend.GetFriendInfoResp{ErrCode: 0, ErrMsg: "",}
|
||||||
|
////
|
||||||
|
//// utils.CopyStructFields(resp.FriendInfoList, friendUserInfo)
|
||||||
|
//// resp.Data.IsBlack = isInBlackList
|
||||||
|
//// resp.Data.OwnerUserID = req.CommID.FromUserID
|
||||||
|
//// resp.Data.Remark = comment
|
||||||
|
//// resp.Data.CreateTime = friendUserInfo.CreateTime
|
||||||
|
////
|
||||||
|
//// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo ok ", resp)
|
||||||
|
//// return &resp, nil
|
||||||
|
////
|
||||||
|
//}
|
||||||
|
@ -141,7 +141,6 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList)
|
|
||||||
utils.CopyStructFields(resp.GroupInfo, group)
|
utils.CopyStructFields(resp.GroupInfo, group)
|
||||||
resp.GroupInfo.MemberCount, err = imdb.GetGroupMemberNumByGroupID(groupId)
|
resp.GroupInfo.MemberCount, err = imdb.GetGroupMemberNumByGroupID(groupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -153,6 +152,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
resp.GroupInfo.OwnerUserID = req.OwnerUserID
|
resp.GroupInfo.OwnerUserID = req.OwnerUserID
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
|
log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String())
|
||||||
|
chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ func (s *groupServer) GetGroupApplicationList(_ context.Context, req *pbGroup.Ge
|
|||||||
}
|
}
|
||||||
|
|
||||||
cp.GroupRequestDBCopyOpenIM(&node, &v)
|
cp.GroupRequestDBCopyOpenIM(&node, &v)
|
||||||
cp.UserDBCopyOpenIMPublic(node.UserInfo, user)
|
cp.UserDBCopyOpenIMPublicUser(node.UserInfo, user)
|
||||||
cp.GroupDBCopyOpenIM(node.GroupInfo, group)
|
cp.GroupDBCopyOpenIM(node.GroupInfo, group)
|
||||||
log.NewDebug(req.OperationID, "node ", node, "v ", v)
|
log.NewDebug(req.OperationID, "node ", node, "v ", v)
|
||||||
resp.GroupRequestList = append(resp.GroupRequestList, &node)
|
resp.GroupRequestList = append(resp.GroupRequestList, &node)
|
||||||
@ -466,30 +466,33 @@ func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.G
|
|||||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), groupRequest)
|
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), groupRequest)
|
||||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
chat.ApplicationProcessedNotification(req)
|
|
||||||
if req.HandleResult == constant.GroupResponseAgree {
|
if req.HandleResult == constant.GroupResponseAgree {
|
||||||
|
user, err := imdb.GetUserByUserID(req.FromUserID)
|
||||||
if req.HandleResult == constant.GroupResponseAgree {
|
if err != nil {
|
||||||
user, err := imdb.GetUserByUserID(req.FromUserID)
|
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.FromUserID)
|
||||||
if err != nil {
|
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), req.FromUserID)
|
|
||||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
||||||
}
|
|
||||||
member := db.GroupMember{}
|
|
||||||
member.GroupID = req.GroupID
|
|
||||||
member.UserID = req.FromUserID
|
|
||||||
member.RoleLevel = constant.GroupOrdinaryUsers
|
|
||||||
member.OperatorUserID = req.OpUserID
|
|
||||||
member.FaceUrl = user.FaceUrl
|
|
||||||
member.Nickname = user.Nickname
|
|
||||||
|
|
||||||
err = imdb.InsertIntoGroupMember(member)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), member)
|
|
||||||
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
member := db.GroupMember{}
|
||||||
|
member.GroupID = req.GroupID
|
||||||
|
member.UserID = req.FromUserID
|
||||||
|
member.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
|
member.OperatorUserID = req.OpUserID
|
||||||
|
member.FaceUrl = user.FaceURL
|
||||||
|
member.Nickname = user.Nickname
|
||||||
|
|
||||||
|
err = imdb.InsertIntoGroupMember(member)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "GroupApplicationResponse failed ", err.Error(), member)
|
||||||
|
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
|
}
|
||||||
|
chat.GroupApplicationAcceptedNotification(req)
|
||||||
chat.MemberEnterNotification(req)
|
chat.MemberEnterNotification(req)
|
||||||
|
} else if req.HandleResult == constant.GroupResponseRefuse {
|
||||||
|
chat.GroupApplicationRejectedNotification(req)
|
||||||
|
} else {
|
||||||
|
log.Error(req.OperationID, "HandleResult failed ", req.HandleResult)
|
||||||
|
return &pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "rpc GroupApplicationResponse return ", pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{}})
|
log.NewInfo(req.OperationID, "rpc GroupApplicationResponse return ", pbGroup.GroupApplicationResponseResp{CommonResp: &pbGroup.CommonResp{}})
|
||||||
@ -521,7 +524,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.JoinApplicationNotification(req)
|
chat.JoinGroupApplicationNotification(req)
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "ReceiveJoinApplicationNotification rpc return ")
|
log.NewInfo(req.OperationID, "ReceiveJoinApplicationNotification rpc return ")
|
||||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
@ -547,7 +550,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
|||||||
// return &pbGroup.CommonResp{ErrorCode: constant.ErrQuitGroup.ErrCode, ErrorMsg: constant.ErrQuitGroup.ErrMsg}, nil
|
// return &pbGroup.CommonResp{ErrorCode: constant.ErrQuitGroup.ErrCode, ErrorMsg: constant.ErrQuitGroup.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
chat.MemberLeaveNotification(req)
|
chat.MemberQuitNotification(req)
|
||||||
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
|
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
|
||||||
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
}
|
}
|
||||||
@ -603,11 +606,10 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
|
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if changedType != 0 {
|
|
||||||
chat.GroupInfoChangedNotification(req.OperationID, req.OpUserID, req.GroupInfo.GroupID, changedType)
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
||||||
|
if changedType != 0 {
|
||||||
|
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfo.GroupID)
|
||||||
|
}
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,8 +632,7 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
|
|||||||
log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo)
|
log.NewError(req.OperationID, "UpdateGroupMemberInfo failed ", groupMemberInfo)
|
||||||
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
changedType := int32(1) << 4
|
chat.GroupOwnerTransferredNotification(req)
|
||||||
chat.GroupInfoChangedNotification(req.OperationID, req.OpUserID, req.GroupID, changedType)
|
|
||||||
|
|
||||||
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
return &pbGroup.TransferGroupOwnerResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func friendNotification(commID *pbFriend.CommID, contentType int32, m proto.Mess
|
|||||||
}
|
}
|
||||||
cn := config.Config.Notification
|
cn := config.Config.Notification
|
||||||
switch contentType {
|
switch contentType {
|
||||||
case constant.FriendApplicationAddedNotification:
|
case constant.FriendApplicationNotification:
|
||||||
|
|
||||||
tips.DefaultTips = fromUserNickname + cn.FriendApplicationAdded.DefaultTips.Tips
|
tips.DefaultTips = fromUserNickname + cn.FriendApplicationAdded.DefaultTips.Tips
|
||||||
case constant.FriendApplicationApprovedNotification:
|
case constant.FriendApplicationApprovedNotification:
|
||||||
@ -69,7 +69,7 @@ func friendNotification(commID *pbFriend.CommID, contentType int32, m proto.Mess
|
|||||||
tips.DefaultTips = cn.FriendAdded.DefaultTips.Tips
|
tips.DefaultTips = cn.FriendAdded.DefaultTips.Tips
|
||||||
case constant.FriendDeletedNotification:
|
case constant.FriendDeletedNotification:
|
||||||
tips.DefaultTips = cn.FriendDeleted.DefaultTips.Tips + toUserNickname
|
tips.DefaultTips = cn.FriendDeleted.DefaultTips.Tips + toUserNickname
|
||||||
case constant.FriendInfoChangedNotification:
|
case constant.FriendRemarkSetNotification:
|
||||||
tips.DefaultTips = fromUserNickname + cn.FriendInfoChanged.DefaultTips.Tips
|
tips.DefaultTips = fromUserNickname + cn.FriendInfoChanged.DefaultTips.Tips
|
||||||
case constant.BlackAddedNotification:
|
case constant.BlackAddedNotification:
|
||||||
tips.DefaultTips = cn.BlackAdded.DefaultTips.Tips + toUserNickname
|
tips.DefaultTips = cn.BlackAdded.DefaultTips.Tips + toUserNickname
|
||||||
@ -95,12 +95,12 @@ func friendNotification(commID *pbFriend.CommID, contentType int32, m proto.Mess
|
|||||||
Notification(&n)
|
Notification(&n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FriendApplicationAddedNotification(req *pbFriend.AddFriendReq) {
|
func FriendApplicationNotification(req *pbFriend.AddFriendReq) {
|
||||||
log.Info(req.CommID.OperationID, utils.GetSelfFuncName(), "args: ", req.String())
|
log.Info(req.CommID.OperationID, utils.GetSelfFuncName(), "args: ", req.String())
|
||||||
var friendApplicationAddedTips open_im_sdk.FriendApplicationAddedTips
|
var friendApplicationAddedTips open_im_sdk.FriendApplicationAddedTips
|
||||||
friendApplicationAddedTips.FromToUserID.FromUserID = req.CommID.FromUserID
|
friendApplicationAddedTips.FromToUserID.FromUserID = req.CommID.FromUserID
|
||||||
friendApplicationAddedTips.FromToUserID.ToUserID = req.CommID.ToUserID
|
friendApplicationAddedTips.FromToUserID.ToUserID = req.CommID.ToUserID
|
||||||
friendNotification(req.CommID, constant.FriendApplicationAddedNotification, &friendApplicationAddedTips)
|
friendNotification(req.CommID, constant.FriendApplicationNotification, &friendApplicationAddedTips)
|
||||||
//fromUserNickname, toUserNickname, err := getFromToUserNickname(req.CommID.FromUserID, req.CommID.ToUserID)
|
//fromUserNickname, toUserNickname, err := getFromToUserNickname(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// log.Error(req.CommID.OperationID, "getFromToUserNickname failed ", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
// log.Error(req.CommID.OperationID, "getFromToUserNickname failed ", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
@ -129,23 +129,18 @@ func FriendApplicationAddedNotification(req *pbFriend.AddFriendReq) {
|
|||||||
//Notification(&n)
|
//Notification(&n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FriendApplicationProcessedNotification(req *pbFriend.AddFriendResponseReq) {
|
func FriendApplicationApprovedNotification(req *pbFriend.AddFriendResponseReq) {
|
||||||
var friendApplicationProcessedTips open_im_sdk.FriendApplicationProcessedTips
|
FriendApplicationApprovedTips := open_im_sdk.FriendApplicationApprovedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
||||||
friendApplicationProcessedTips.FromToUserID.FromUserID = req.CommID.FromUserID
|
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.CommID.FromUserID
|
||||||
friendApplicationProcessedTips.FromToUserID.ToUserID = req.CommID.ToUserID
|
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.CommID.ToUserID
|
||||||
friendApplicationProcessedTips.HandleResult = req.HandleResult
|
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
||||||
//fromUserNickname, toUserNickname, err := getFromToUserNickname(req.CommID.FromUserID, req.CommID.ToUserID)
|
//fromUserNickname, toUserNickname, err := getFromToUserNickname(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// log.Error(req.CommID.OperationID, "getFromToUserNickname failed ", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
// log.Error(req.CommID.OperationID, "getFromToUserNickname failed ", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
// return
|
// return
|
||||||
//}
|
//}
|
||||||
if friendApplicationProcessedTips.HandleResult == 1 {
|
|
||||||
friendNotification(req.CommID, constant.FriendApplicationApprovedNotification, &friendApplicationProcessedTips)
|
friendNotification(req.CommID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips)
|
||||||
} else if friendApplicationProcessedTips.HandleResult == -1 {
|
|
||||||
friendNotification(req.CommID, constant.FriendApplicationRejectedNotification, &friendApplicationProcessedTips)
|
|
||||||
} else {
|
|
||||||
log.Error(req.CommID.OperationID, "HandleResult failed ", friendApplicationProcessedTips.HandleResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
//var tips open_im_sdk.TipsComm
|
//var tips open_im_sdk.TipsComm
|
||||||
//tips.DefaultTips = fromUserNickname + " FriendApplicationProcessedNotification " + toUserNickname
|
//tips.DefaultTips = fromUserNickname + " FriendApplicationProcessedNotification " + toUserNickname
|
||||||
@ -170,6 +165,58 @@ func FriendApplicationProcessedNotification(req *pbFriend.AddFriendResponseReq)
|
|||||||
//Notification(&n)
|
//Notification(&n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FriendApplicationRejectedNotification(req *pbFriend.AddFriendResponseReq) {
|
||||||
|
FriendApplicationApprovedTips := open_im_sdk.FriendApplicationApprovedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
||||||
|
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.CommID.FromUserID
|
||||||
|
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.CommID.ToUserID
|
||||||
|
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
||||||
|
|
||||||
|
friendNotification(req.CommID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//func FriendApplicationProcessedNotification(req *pbFriend.AddFriendResponseReq) {
|
||||||
|
// var friendApplicationProcessedTips open_im_sdk.FriendApplicationProcessedTips
|
||||||
|
// friendApplicationProcessedTips.FromToUserID.FromUserID = req.CommID.FromUserID
|
||||||
|
// friendApplicationProcessedTips.FromToUserID.ToUserID = req.CommID.ToUserID
|
||||||
|
// friendApplicationProcessedTips.HandleResult = req.HandleResult
|
||||||
|
// //fromUserNickname, toUserNickname, err := getFromToUserNickname(req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
|
// //if err != nil {
|
||||||
|
// // log.Error(req.CommID.OperationID, "getFromToUserNickname failed ", err.Error(), req.CommID.FromUserID, req.CommID.ToUserID)
|
||||||
|
// // return
|
||||||
|
// //}
|
||||||
|
// if friendApplicationProcessedTips.HandleResult == 1 {
|
||||||
|
// friendNotification(req.CommID, constant.FriendApplicationApprovedNotification, &friendApplicationProcessedTips)
|
||||||
|
// } else if friendApplicationProcessedTips.HandleResult == -1 {
|
||||||
|
// friendNotification(req.CommID, constant.FriendApplicationRejectedNotification, &friendApplicationProcessedTips)
|
||||||
|
// } else {
|
||||||
|
// log.Error(req.CommID.OperationID, "HandleResult failed ", friendApplicationProcessedTips.HandleResult)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //var tips open_im_sdk.TipsComm
|
||||||
|
// //tips.DefaultTips = fromUserNickname + " FriendApplicationProcessedNotification " + toUserNickname
|
||||||
|
// //tips.Detail, err = proto.Marshal(&friendApplicationProcessedTips)
|
||||||
|
// //if err != nil {
|
||||||
|
// // log.Error(req.CommID.OperationID, "Marshal failed ", err.Error(), friendApplicationProcessedTips.String())
|
||||||
|
// // return
|
||||||
|
// //}
|
||||||
|
// //
|
||||||
|
// //var n NotificationMsg
|
||||||
|
// //n.SendID = req.CommID.FromUserID
|
||||||
|
// //n.RecvID = req.CommID.ToUserID
|
||||||
|
// //n.ContentType = constant.FriendApplicationProcessedNotification
|
||||||
|
// //n.SessionType = constant.SingleChatType
|
||||||
|
// //n.MsgFrom = constant.SysMsgType
|
||||||
|
// //n.OperationID = req.CommID.OperationID
|
||||||
|
// //n.Content, err = proto.Marshal(&tips)
|
||||||
|
// //if err != nil {
|
||||||
|
// // log.Error(req.CommID.OperationID, "Marshal failed ", err.Error(), tips.String())
|
||||||
|
// // return
|
||||||
|
// //}
|
||||||
|
// //Notification(&n)
|
||||||
|
//}
|
||||||
|
|
||||||
func FriendAddedNotification(operationID, opUserID, fromUserID, toUserID string) {
|
func FriendAddedNotification(operationID, opUserID, fromUserID, toUserID string) {
|
||||||
var friendAddedTips open_im_sdk.FriendAddedTips
|
var friendAddedTips open_im_sdk.FriendAddedTips
|
||||||
user, err := imdb.GetUserByUserID(opUserID)
|
user, err := imdb.GetUserByUserID(opUserID)
|
||||||
@ -255,7 +302,7 @@ func FriendDeletedNotification(req *pbFriend.DeleteFriendReq) {
|
|||||||
// PublicUserInfo OpUser = 2;
|
// PublicUserInfo OpUser = 2;
|
||||||
// uint64 OperationTime = 3;
|
// uint64 OperationTime = 3;
|
||||||
//}
|
//}
|
||||||
func FriendInfoChangedNotification(operationID, opUserID, fromUserID, toUserID string) {
|
func FriendRemarkSetNotification(operationID, opUserID, fromUserID, toUserID string) {
|
||||||
var friendInfoChangedTips open_im_sdk.FriendInfoChangedTips
|
var friendInfoChangedTips open_im_sdk.FriendInfoChangedTips
|
||||||
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
||||||
friendInfoChangedTips.FromToUserID.ToUserID = toUserID
|
friendInfoChangedTips.FromToUserID.ToUserID = toUserID
|
||||||
@ -265,7 +312,7 @@ func FriendInfoChangedNotification(operationID, opUserID, fromUserID, toUserID s
|
|||||||
// return
|
// return
|
||||||
//}
|
//}
|
||||||
commID := pbFriend.CommID{FromUserID: fromUserID, ToUserID: toUserID, OpUserID: opUserID, OperationID: operationID}
|
commID := pbFriend.CommID{FromUserID: fromUserID, ToUserID: toUserID, OpUserID: opUserID, OperationID: operationID}
|
||||||
friendNotification(&commID, constant.FriendInfoChangedNotification, &friendInfoChangedTips)
|
friendNotification(&commID, constant.FriendRemarkSetNotification, &friendInfoChangedTips)
|
||||||
//var tips open_im_sdk.TipsComm
|
//var tips open_im_sdk.TipsComm
|
||||||
//tips.DefaultTips = fromUserNickname + " FriendDeletedNotification " + toUserNickname
|
//tips.DefaultTips = fromUserNickname + " FriendDeletedNotification " + toUserNickname
|
||||||
//tips.Detail, err = proto.Marshal(&friendInfoChangedTips)
|
//tips.Detail, err = proto.Marshal(&friendInfoChangedTips)
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"encoding/json"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//message GroupCreatedTips{
|
//message GroupCreatedTips{
|
||||||
@ -63,46 +63,114 @@ func setGroupMemberInfo(groupID, userID string, groupMemberInfo *open_im_sdk.Gro
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//func setGroupPublicUserInfo(operationID, groupID, userID string, publicUserInfo *open_im_sdk.PublicUserInfo) {
|
func setGroupOwnerInfo(groupID string, groupMemberInfo *open_im_sdk.GroupMemberFullInfo) error {
|
||||||
// group, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID)
|
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(groupID)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// log.NewError(operationID, "FindGroupMemberInfoByGroupIdAndUserId failed ", err.Error(), groupID, userID)
|
return utils.Wrap(err, "")
|
||||||
// return
|
}
|
||||||
// }
|
if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember); err != nil {
|
||||||
// utils.CopyStructFields(publicUserInfo, group)
|
return utils.Wrap(err, "")
|
||||||
//}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setPublicUserInfo(userID string, publicUserInfo *open_im_sdk.PublicUserInfo) error {
|
||||||
|
user, err := imdb.GetUserByUserID(userID)
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
utils2.UserDBCopyOpenIMPublicUser(publicUserInfo, user)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) {
|
||||||
|
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
var tips open_im_sdk.TipsComm
|
||||||
|
tips.Detail, err = proto.Marshal(m)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cn := config.Config.Notification
|
||||||
|
switch contentType {
|
||||||
|
case constant.GroupCreatedNotification:
|
||||||
|
tips.DefaultTips = cn.GroupCreated.DefaultTips.Tips
|
||||||
|
case constant.GroupInfoSetNotification:
|
||||||
|
case constant.JoinGroupApplicationNotification:
|
||||||
|
case constant.MemberQuitNotification:
|
||||||
|
case constant.GroupApplicationAcceptedNotification:
|
||||||
|
case constant.GroupApplicationRejectedNotification:
|
||||||
|
case constant.GroupOwnerTransferredNotification:
|
||||||
|
case constant.MemberKickedNotification:
|
||||||
|
case constant.MemberInvitedNotification:
|
||||||
|
default:
|
||||||
|
log.Error(operationID, "contentType failed ", contentType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var n NotificationMsg
|
||||||
|
n.SendID = sendID
|
||||||
|
if groupID != "" {
|
||||||
|
n.RecvID = groupID
|
||||||
|
n.SessionType = constant.GroupChatType
|
||||||
|
} else {
|
||||||
|
n.RecvID = recvUserID
|
||||||
|
n.SessionType = constant.SingleChatType
|
||||||
|
}
|
||||||
|
n.ContentType = contentType
|
||||||
|
n.OperationID = operationID
|
||||||
|
n.Content, err = proto.Marshal(&tips)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Notification(&n)
|
||||||
|
}
|
||||||
|
|
||||||
//创建群后调用
|
//创建群后调用
|
||||||
func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) {
|
func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) {
|
||||||
GroupCreatedTips := open_im_sdk.GroupCreatedTips{Group: &open_im_sdk.GroupInfo{},
|
GroupCreatedTips := open_im_sdk.GroupCreatedTips{Group: &open_im_sdk.GroupInfo{},
|
||||||
Creator: &open_im_sdk.GroupMemberFullInfo{}}
|
OpUser: &open_im_sdk.GroupMemberFullInfo{}, GroupOwnerUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
if err := setOpUserInfo(GroupCreatedTips.Creator.UserID, groupID, GroupCreatedTips.Creator); err != nil {
|
if err := setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil {
|
||||||
log.NewError(operationID, "setOpUserInfo failed ", err.Error(), GroupCreatedTips.Creator.UserID, groupID, GroupCreatedTips.Creator)
|
log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := setGroupInfo(groupID, GroupCreatedTips.Group)
|
err := setGroupInfo(groupID, GroupCreatedTips.Group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group)
|
log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
imdb.GetGroupOwnerInfoByGroupID(groupID)
|
||||||
|
if err := setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil {
|
||||||
|
log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range initMemberList {
|
for _, v := range initMemberList {
|
||||||
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
|
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
|
||||||
setGroupMemberInfo(groupID, v, &groupMemberInfo)
|
if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
||||||
|
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v)
|
||||||
|
continue
|
||||||
|
}
|
||||||
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
|
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
|
||||||
}
|
}
|
||||||
var tips open_im_sdk.TipsComm
|
groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID)
|
||||||
tips.Detail, _ = json.Marshal(GroupCreatedTips)
|
}
|
||||||
tips.DefaultTips = config.Config.Notification.GroupCreated.DefaultTips.Tips
|
|
||||||
var n NotificationMsg
|
//群信息改变后掉用
|
||||||
n.SendID = opUserID
|
func GroupInfoSetNotification(operationID, opUserID, groupID string) {
|
||||||
n.RecvID = groupID
|
GroupInfoChangedTips := open_im_sdk.GroupInfoSetTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
n.ContentType = constant.GroupCreatedNotification
|
if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
|
||||||
n.SessionType = constant.GroupChatType
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
n.MsgFrom = constant.SysMsgType
|
return
|
||||||
n.OperationID = operationID
|
}
|
||||||
n.Content, _ = json.Marshal(tips)
|
if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
||||||
log.NewInfo(operationID, "Notification ", n)
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
Notification(&n)
|
return
|
||||||
|
}
|
||||||
|
groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
//message ReceiveJoinApplicationTips{
|
//message ReceiveJoinApplicationTips{
|
||||||
@ -114,44 +182,46 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL
|
|||||||
// OpUserID string `protobuf:"bytes,3,opt,name=OpUserID" json:"OpUserID,omitempty"`
|
// OpUserID string `protobuf:"bytes,3,opt,name=OpUserID" json:"OpUserID,omitempty"`
|
||||||
// OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"`
|
// OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||||
//申请进群后调用
|
//申请进群后调用
|
||||||
func JoinApplicationNotification(req *pbGroup.JoinGroupReq) {
|
func JoinGroupApplicationNotification(req *pbGroup.JoinGroupReq) {
|
||||||
JoinGroupApplicationTips := open_im_sdk.JoinGroupApplicationTips{Group: &open_im_sdk.GroupInfo{}, Applicant: &open_im_sdk.PublicUserInfo{}}
|
JoinGroupApplicationTips := open_im_sdk.JoinGroupApplicationTips{Group: &open_im_sdk.GroupInfo{}, Applicant: &open_im_sdk.PublicUserInfo{}}
|
||||||
err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group)
|
err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, JoinGroupApplicationTips.Group)
|
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if err = setPublicUserInfo(req.OpUserID, JoinGroupApplicationTips.Applicant); err != nil {
|
||||||
apply, err := imdb.GetUserByUserID(req.OpUserID)
|
log.Error(req.OperationID, "setPublicUserInfo failed ", err.Error(), req.OpUserID)
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "FindUserByUID failed ", err.Error(), req.OpUserID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(JoinGroupApplicationTips.Applicant, apply)
|
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
|
||||||
JoinGroupApplicationTips.Reason = req.ReqMessage
|
|
||||||
|
|
||||||
var tips open_im_sdk.TipsComm
|
|
||||||
tips.Detail, _ = json.Marshal(JoinGroupApplicationTips)
|
|
||||||
tips.DefaultTips = "JoinGroupApplicationTips"
|
|
||||||
var n NotificationMsg
|
|
||||||
n.SendID = req.OpUserID
|
|
||||||
n.ContentType = constant.JoinApplicationNotification
|
|
||||||
n.SessionType = constant.SingleChatType
|
|
||||||
n.MsgFrom = constant.SysMsgType
|
|
||||||
n.OperationID = req.OperationID
|
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID)
|
log.NewError(req.OperationID, "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range managerList {
|
for _, v := range managerList {
|
||||||
n.RecvID = v.UserID
|
groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, req.OpUserID, "", v.UserID, req.OperationID)
|
||||||
log.NewInfo(req.OperationID, "Notification ", n)
|
log.NewInfo(req.OperationID, "Notification ", v)
|
||||||
Notification(&n)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MemberQuitNotification(req *pbGroup.QuitGroupReq) {
|
||||||
|
MemberQuitTips := open_im_sdk.MemberQuitTips{Group: &open_im_sdk.GroupInfo{}, QuitUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
if err := setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil {
|
||||||
|
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil {
|
||||||
|
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID)
|
||||||
|
groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, "", req.OpUserID, req.OperationID)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//message ApplicationProcessedTips{
|
//message ApplicationProcessedTips{
|
||||||
// GroupInfo Group = 1;
|
// GroupInfo Group = 1;
|
||||||
// GroupMemberFullInfo OpUser = 2;
|
// GroupMemberFullInfo OpUser = 2;
|
||||||
@ -159,70 +229,47 @@ func JoinApplicationNotification(req *pbGroup.JoinGroupReq) {
|
|||||||
// string Reason = 4;
|
// string Reason = 4;
|
||||||
//}
|
//}
|
||||||
//处理进群请求后调用
|
//处理进群请求后调用
|
||||||
func ApplicationProcessedNotification(req *pbGroup.GroupApplicationResponseReq) {
|
func GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) {
|
||||||
ApplicationProcessedTips := open_im_sdk.ApplicationProcessedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
GroupApplicationAcceptedTips := open_im_sdk.GroupApplicationAcceptedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
|
||||||
if err := setGroupInfo(req.GroupID, ApplicationProcessedTips.Group); err != nil {
|
if err := setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil {
|
||||||
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, ApplicationProcessedTips.Group)
|
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationAcceptedTips.Group)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := setOpUserInfo(req.OpUserID, req.GroupID, ApplicationProcessedTips.OpUser); err != nil {
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil {
|
||||||
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, ApplicationProcessedTips.OpUser)
|
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ApplicationProcessedTips.Reason = req.HandledMsg
|
groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID)
|
||||||
ApplicationProcessedTips.Result = req.HandleResult
|
|
||||||
|
|
||||||
var tips open_im_sdk.TipsComm
|
|
||||||
tips.Detail, _ = json.Marshal(ApplicationProcessedTips)
|
|
||||||
tips.DefaultTips = "ApplicationProcessedNotification"
|
|
||||||
var n NotificationMsg
|
|
||||||
n.SendID = req.OpUserID
|
|
||||||
n.ContentType = constant.ApplicationProcessedNotification
|
|
||||||
n.SessionType = constant.SingleChatType
|
|
||||||
n.MsgFrom = constant.SysMsgType
|
|
||||||
n.OperationID = req.OperationID
|
|
||||||
n.RecvID = req.FromUserID
|
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
Notification(&n)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//message MemberInvitedTips{
|
func GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) {
|
||||||
// GroupInfo Group = 1;
|
GroupApplicationRejectedTips := open_im_sdk.GroupApplicationRejectedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
|
||||||
// GroupMemberFullInfo OpUser = 2;
|
if err := setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil {
|
||||||
// GroupMemberFullInfo InvitedUser = 3;
|
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationRejectedTips.Group)
|
||||||
// uint64 OperationTime = 4;
|
|
||||||
//}
|
|
||||||
//被邀请进群后调用
|
|
||||||
func MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) {
|
|
||||||
ApplicationProcessedTips := open_im_sdk.MemberInvitedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
|
||||||
if err := setGroupInfo(groupID, ApplicationProcessedTips.Group); err != nil {
|
|
||||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, ApplicationProcessedTips.Group)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := setOpUserInfo(opUserID, groupID, ApplicationProcessedTips.OpUser); err != nil {
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil {
|
||||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, ApplicationProcessedTips.OpUser)
|
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range invitedUserIDList {
|
groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID)
|
||||||
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
|
}
|
||||||
if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
|
||||||
log.Error(operationID, "setGroupMemberInfo faield ", err.Error(), groupID)
|
func GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) {
|
||||||
continue
|
GroupOwnerTransferredTips := open_im_sdk.GroupOwnerTransferredTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, NewGroupOwner: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
}
|
if err := setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil {
|
||||||
ApplicationProcessedTips.InvitedUserList = append(ApplicationProcessedTips.InvitedUserList, &groupMemberInfo)
|
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
var tips open_im_sdk.TipsComm
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil {
|
||||||
tips.Detail, _ = json.Marshal(ApplicationProcessedTips)
|
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID)
|
||||||
tips.DefaultTips = "MemberInvitedNotification"
|
return
|
||||||
var n NotificationMsg
|
}
|
||||||
n.SendID = opUserID
|
if err := setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil {
|
||||||
n.ContentType = constant.MemberInvitedNotification
|
log.Error(req.OperationID, "setGroupMemberInfo failed", req.GroupID, req.NewOwnerUserID)
|
||||||
n.SessionType = constant.GroupChatType
|
return
|
||||||
n.MsgFrom = constant.SysMsgType
|
}
|
||||||
n.OperationID = operationID
|
groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, "", req.NewOwnerUserID, req.OperationID)
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
n.RecvID = groupID
|
|
||||||
Notification(&n)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//message MemberKickedTips{
|
//message MemberKickedTips{
|
||||||
@ -235,11 +282,11 @@ func MemberInvitedNotification(operationID, groupID, opUserID, reason string, in
|
|||||||
func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) {
|
func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) {
|
||||||
MemberKickedTips := open_im_sdk.MemberKickedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
MemberKickedTips := open_im_sdk.MemberKickedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
if err := setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil {
|
if err := setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil {
|
||||||
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberKickedTips.Group)
|
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil {
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil {
|
||||||
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberKickedTips.OpUser)
|
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range kickedUserIDList {
|
for _, v := range kickedUserIDList {
|
||||||
@ -250,60 +297,48 @@ func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList
|
|||||||
}
|
}
|
||||||
MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo)
|
MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo)
|
||||||
}
|
}
|
||||||
|
groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID)
|
||||||
var tips open_im_sdk.TipsComm
|
|
||||||
tips.Detail, _ = json.Marshal(MemberKickedTips)
|
|
||||||
tips.DefaultTips = "MemberKickedNotification"
|
|
||||||
var n NotificationMsg
|
|
||||||
n.SendID = req.OpUserID
|
|
||||||
n.ContentType = constant.MemberKickedNotification
|
|
||||||
n.SessionType = constant.GroupChatType
|
|
||||||
n.MsgFrom = constant.SysMsgType
|
|
||||||
n.OperationID = req.OperationID
|
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
n.RecvID = req.GroupID
|
|
||||||
Notification(&n)
|
|
||||||
|
|
||||||
for _, v := range kickedUserIDList {
|
for _, v := range kickedUserIDList {
|
||||||
m := n
|
groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID)
|
||||||
m.SessionType = constant.SingleChatType
|
|
||||||
m.RecvID = v
|
|
||||||
Notification(&m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//message MemberInvitedTips{
|
||||||
|
// GroupInfo Group = 1;
|
||||||
|
// GroupMemberFullInfo OpUser = 2;
|
||||||
|
// GroupMemberFullInfo InvitedUser = 3;
|
||||||
|
// uint64 OperationTime = 4;
|
||||||
|
//}
|
||||||
|
//被邀请进群后调用
|
||||||
|
func MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) {
|
||||||
|
MemberInvitedTips := open_im_sdk.MemberInvitedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
|
if err := setGroupInfo(groupID, MemberInvitedTips.Group); err != nil {
|
||||||
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil {
|
||||||
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range invitedUserIDList {
|
||||||
|
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
|
||||||
|
if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
||||||
|
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID)
|
||||||
|
}
|
||||||
|
|
||||||
//message GroupInfoChangedTips{
|
//message GroupInfoChangedTips{
|
||||||
// int32 ChangedType = 1; //bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl
|
// int32 ChangedType = 1; //bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl
|
||||||
// GroupInfo Group = 2;
|
// GroupInfo Group = 2;
|
||||||
// GroupMemberFullInfo OpUser = 3;
|
// GroupMemberFullInfo OpUser = 3;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//群信息改变后掉用
|
|
||||||
func GroupInfoChangedNotification(operationID, opUserID, groupID string, changedType int32) {
|
|
||||||
GroupInfoChangedTips := open_im_sdk.GroupInfoChangedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
|
|
||||||
if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
|
|
||||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, GroupInfoChangedTips.Group)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
|
||||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupInfoChangedTips.OpUser)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
GroupInfoChangedTips.ChangedType = changedType
|
|
||||||
var tips open_im_sdk.TipsComm
|
|
||||||
tips.Detail, _ = json.Marshal(GroupInfoChangedTips)
|
|
||||||
tips.DefaultTips = "GroupInfoChangedNotification"
|
|
||||||
var n NotificationMsg
|
|
||||||
n.SendID = opUserID
|
|
||||||
n.ContentType = constant.GroupInfoChangedNotification
|
|
||||||
n.SessionType = constant.GroupChatType
|
|
||||||
n.MsgFrom = constant.SysMsgType
|
|
||||||
n.OperationID = operationID
|
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
n.RecvID = groupID
|
|
||||||
Notification(&n)
|
|
||||||
}
|
|
||||||
|
|
||||||
//message MemberLeaveTips{
|
//message MemberLeaveTips{
|
||||||
// GroupInfo Group = 1;
|
// GroupInfo Group = 1;
|
||||||
// GroupMemberFullInfo LeaverUser = 2;
|
// GroupMemberFullInfo LeaverUser = 2;
|
||||||
@ -311,35 +346,6 @@ func GroupInfoChangedNotification(operationID, opUserID, groupID string, changed
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
//群成员退群后调用
|
//群成员退群后调用
|
||||||
func MemberLeaveNotification(req *pbGroup.QuitGroupReq) {
|
|
||||||
MemberLeaveTips := open_im_sdk.MemberLeaveTips{Group: &open_im_sdk.GroupInfo{}, LeaverUser: &open_im_sdk.GroupMemberFullInfo{}}
|
|
||||||
if err := setGroupInfo(req.GroupID, MemberLeaveTips.Group); err != nil {
|
|
||||||
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberLeaveTips.Group)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberLeaveTips.LeaverUser); err != nil {
|
|
||||||
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberLeaveTips.LeaverUser)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var tips open_im_sdk.TipsComm
|
|
||||||
tips.Detail, _ = json.Marshal(MemberLeaveTips)
|
|
||||||
tips.DefaultTips = "MemberLeaveNotification"
|
|
||||||
var n NotificationMsg
|
|
||||||
n.SendID = req.OpUserID
|
|
||||||
n.ContentType = constant.MemberLeaveNotification
|
|
||||||
n.SessionType = constant.GroupChatType
|
|
||||||
n.MsgFrom = constant.SysMsgType
|
|
||||||
n.OperationID = req.OperationID
|
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
n.RecvID = req.GroupID
|
|
||||||
Notification(&n)
|
|
||||||
|
|
||||||
m := n
|
|
||||||
n.SessionType = constant.SingleChatType
|
|
||||||
n.RecvID = req.OpUserID
|
|
||||||
Notification(&m)
|
|
||||||
}
|
|
||||||
|
|
||||||
//message MemberEnterTips{
|
//message MemberEnterTips{
|
||||||
// GroupInfo Group = 1;
|
// GroupInfo Group = 1;
|
||||||
@ -348,25 +354,15 @@ func MemberLeaveNotification(req *pbGroup.QuitGroupReq) {
|
|||||||
//}
|
//}
|
||||||
//群成员主动申请进群,管理员同意后调用,
|
//群成员主动申请进群,管理员同意后调用,
|
||||||
func MemberEnterNotification(req *pbGroup.GroupApplicationResponseReq) {
|
func MemberEnterNotification(req *pbGroup.GroupApplicationResponseReq) {
|
||||||
MemberLeaveTips := open_im_sdk.MemberEnterTips{Group: &open_im_sdk.GroupInfo{}, EntrantUser: &open_im_sdk.GroupMemberFullInfo{}}
|
MemberEnterTips := open_im_sdk.MemberEnterTips{Group: &open_im_sdk.GroupInfo{}, EntrantUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||||
if err := setGroupInfo(req.GroupID, MemberLeaveTips.Group); err != nil {
|
if err := setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil {
|
||||||
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberLeaveTips.Group)
|
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberEnterTips.Group)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberLeaveTips.EntrantUser); err != nil {
|
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser); err != nil {
|
||||||
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberLeaveTips.EntrantUser)
|
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var tips open_im_sdk.TipsComm
|
groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID)
|
||||||
tips.Detail, _ = json.Marshal(MemberLeaveTips)
|
|
||||||
tips.DefaultTips = "MemberEnterNotification"
|
|
||||||
var n NotificationMsg
|
|
||||||
n.SendID = req.OpUserID
|
|
||||||
n.ContentType = constant.MemberEnterNotification
|
|
||||||
n.SessionType = constant.GroupChatType
|
|
||||||
n.MsgFrom = constant.SysMsgType
|
|
||||||
n.OperationID = req.OperationID
|
|
||||||
n.Content, _ = json.Marshal(tips)
|
|
||||||
n.RecvID = req.GroupID
|
|
||||||
Notification(&n)
|
|
||||||
}
|
}
|
||||||
|
@ -46,35 +46,27 @@ const (
|
|||||||
|
|
||||||
//SysRelated
|
//SysRelated
|
||||||
|
|
||||||
FriendApplicationApprovedNotification = 1201
|
FriendApplicationApprovedNotification = 1201 //add_friend_response
|
||||||
FriendApplicationRejectedNotification = 1202
|
FriendApplicationRejectedNotification = 1202 //add_friend_response
|
||||||
FriendApplicationAddedNotification = 1203 //AddFriendTip = 202
|
FriendApplicationNotification = 1203 //add_friend
|
||||||
FriendAddedNotification = 1204
|
FriendAddedNotification = 1204
|
||||||
FriendDeletedNotification = 1205
|
FriendDeletedNotification = 1205 //delete_friend
|
||||||
FriendInfoChangedNotification = 1206
|
FriendRemarkSetNotification = 1206 //set_friend_remark?
|
||||||
BlackAddedNotification = 1207
|
BlackAddedNotification = 1207 //add_black
|
||||||
BlackDeletedNotification = 1208
|
BlackDeletedNotification = 1208 //remove_black
|
||||||
|
|
||||||
SelfInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
SelfInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
||||||
|
|
||||||
GroupCreatedNotification = 1501
|
GroupCreatedNotification = 1501
|
||||||
MemberInfoSetNotification = 1501
|
GroupInfoSetNotification = 1502
|
||||||
JoinGroupApplicationNotification = 1501
|
JoinGroupApplicationNotification = 1503
|
||||||
MemberQuitNotification = 1501
|
MemberQuitNotification = 1504
|
||||||
GroupApplicationAcceptedNotification = 1501
|
GroupApplicationAcceptedNotification = 1505
|
||||||
GroupApplicationRejectedNotification = 1501
|
GroupApplicationRejectedNotification = 1506
|
||||||
GroupOwnerTransferredNotification = 1501
|
GroupOwnerTransferredNotification = 1507
|
||||||
MemberKickedNotification = 1501
|
MemberKickedNotification = 1508
|
||||||
MemberInvitedNotification = 1501
|
MemberInvitedNotification = 1509
|
||||||
|
MemberEnterNotification = 1510
|
||||||
//GroupCreatedNotification = 1501
|
|
||||||
//JoinApplicationNotification = 1502
|
|
||||||
//ApplicationProcessedNotification = 1503
|
|
||||||
//MemberInvitedNotification = 1504
|
|
||||||
//MemberKickedNotification = 1505
|
|
||||||
//GroupInfoChangedNotification = 1506
|
|
||||||
//MemberLeaveNotification = 1507
|
|
||||||
//MemberEnterNotification = 1508
|
|
||||||
|
|
||||||
//MsgFrom
|
//MsgFrom
|
||||||
UserMsgType = 100
|
UserMsgType = 100
|
||||||
@ -140,6 +132,9 @@ const (
|
|||||||
GroupResponseAgree = 1
|
GroupResponseAgree = 1
|
||||||
GroupResponseRefuse = -1
|
GroupResponseRefuse = -1
|
||||||
|
|
||||||
|
FriendResponseAgree = 1
|
||||||
|
FriendResponseRefuse = -1
|
||||||
|
|
||||||
Male = 1
|
Male = 1
|
||||||
Female = 2
|
Female = 2
|
||||||
)
|
)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -228,13 +228,14 @@ message TipsComm{
|
|||||||
// OnGroupCreated()
|
// OnGroupCreated()
|
||||||
message GroupCreatedTips{
|
message GroupCreatedTips{
|
||||||
GroupInfo group = 1;
|
GroupInfo group = 1;
|
||||||
GroupMemberFullInfo creator = 2;
|
GroupMemberFullInfo opUser = 2;
|
||||||
repeated GroupMemberFullInfo memberList = 3;
|
repeated GroupMemberFullInfo memberList = 3;
|
||||||
int64 operationTime = 4;
|
int64 operationTime = 4;
|
||||||
|
GroupMemberFullInfo groupOwnerUser = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnGroupInfoSet()
|
// OnGroupInfoSet()
|
||||||
message MemberInfoSetTips{
|
message GroupInfoSetTips{
|
||||||
GroupMemberFullInfo opUser = 1; //who do this
|
GroupMemberFullInfo opUser = 1; //who do this
|
||||||
int64 muteTime = 2;
|
int64 muteTime = 2;
|
||||||
GroupInfo group = 3;
|
GroupInfo group = 3;
|
||||||
@ -244,7 +245,7 @@ message MemberInfoSetTips{
|
|||||||
message JoinGroupApplicationTips{
|
message JoinGroupApplicationTips{
|
||||||
GroupInfo group = 1;
|
GroupInfo group = 1;
|
||||||
PublicUserInfo applicant = 2;
|
PublicUserInfo applicant = 2;
|
||||||
string reason = 3;
|
string reqMsg = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnQuitGroup()
|
// OnQuitGroup()
|
||||||
@ -296,29 +297,10 @@ message MemberInvitedTips{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Actively join the group
|
//Actively join the group
|
||||||
//message MemberEnterTips{
|
message MemberEnterTips{
|
||||||
// GroupInfo group = 1;
|
|
||||||
// GroupMemberFullInfo entrantUser = 2;
|
|
||||||
// int64 operationTime = 3;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
message GroupInfoChangedTips{
|
|
||||||
int32 changedType = 1; //bitwise operators: 0001:groupName; 0010:Notification 0100:Introduction; 1000:FaceUrl
|
|
||||||
GroupInfo group = 2;
|
|
||||||
GroupMemberFullInfo opUser = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message JoinGroupApplicationTips{
|
|
||||||
GroupInfo group = 1;
|
GroupInfo group = 1;
|
||||||
PublicUserInfo applicant = 2;
|
GroupMemberFullInfo entrantUser = 2;
|
||||||
string reason = 3;
|
int64 operationTime = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -326,6 +308,11 @@ message JoinGroupApplicationTips{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////friend/////////////////////
|
//////////////////////friend/////////////////////
|
||||||
//message FriendInfo{
|
//message FriendInfo{
|
||||||
// UserInfo OwnerUser = 1;
|
// UserInfo OwnerUser = 1;
|
||||||
@ -351,11 +338,18 @@ message FriendApplicationAddedTips{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//FromUserID accept or reject ToUserID
|
//FromUserID accept or reject ToUserID
|
||||||
message FriendApplicationProcessedTips{
|
message FriendApplicationApprovedTips{
|
||||||
FromToUserID fromToUserID = 1;
|
FromToUserID fromToUserID = 1;
|
||||||
int32 handleResult = 2;
|
string handleMsg = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FromUserID accept or reject ToUserID
|
||||||
|
message FriendApplicationRejectedTips{
|
||||||
|
FromToUserID fromToUserID = 1;
|
||||||
|
string handleMsg = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// FromUserID Added a friend ToUserID
|
// FromUserID Added a friend ToUserID
|
||||||
message FriendAddedTips{
|
message FriendAddedTips{
|
||||||
FriendInfo friend = 1;
|
FriendInfo friend = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user