mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 10:35:59 +08:00
Merge remote-tracking branch 'origin/superGroup' into superGroup
This commit is contained in:
@@ -606,6 +606,10 @@ func SetGroupInfo(c *gin.Context) {
|
||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
|
||||
if params.NeedVerification != nil {
|
||||
req.GroupInfo.NeedVerification = &wrappers.Int32Value{Value: *params.NeedVerification}
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
|
||||
@@ -195,6 +195,14 @@ func GetUsersInfo(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 修改用户信息
|
||||
// @Description 修改用户信息
|
||||
// @Tags 修改用户信息
|
||||
// @Accept json
|
||||
// @Param who query string true "人名"
|
||||
// @Success 200 {string} string "{"msg": "hello Razeen"}"
|
||||
// @Failure 400 {string} string "{"msg": "who are you"}"
|
||||
// @Router /update_user_info [post]
|
||||
func UpdateUserInfo(c *gin.Context) {
|
||||
params := api.UpdateSelfUserInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -233,6 +241,7 @@ func UpdateUserInfo(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||
params := api.SetGlobalRecvMessageOptReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
|
||||
@@ -20,6 +20,7 @@ type ParamsLogin struct {
|
||||
Password string `json:"password"`
|
||||
Platform int32 `json:"platform"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
}
|
||||
|
||||
func Login(c *gin.Context) {
|
||||
@@ -35,7 +36,7 @@ func Login(c *gin.Context) {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
|
||||
r, err := im_mysql_model.GetRegister(account)
|
||||
r, err := im_mysql_model.GetRegister(account, params.AreaCode)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "user have not register", params.Password, account, err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "Mobile phone number is not registered"})
|
||||
|
||||
@@ -21,9 +21,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func onboardingProcess(operationID, userID, userName, faceURL string) {
|
||||
func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, email string) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userName, userID, faceURL)
|
||||
if err := createOrganizationUser(operationID, userID, userName); err != nil {
|
||||
if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
|
||||
}
|
||||
departmentID, err := imdb.GetRandomDepartmentID()
|
||||
@@ -45,7 +45,7 @@ func onboardingProcess(operationID, userID, userName, faceURL string) {
|
||||
oaNotification(operationID, userID)
|
||||
}
|
||||
|
||||
func createOrganizationUser(operationID, userID, userName string) error {
|
||||
func createOrganizationUser(operationID, userID, userName, phoneNumber, email string) error {
|
||||
defer func() {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userID)
|
||||
}()
|
||||
@@ -64,16 +64,15 @@ func createOrganizationUser(operationID, userID, userName string) error {
|
||||
EnglishName: randomEnglishName(),
|
||||
Gender: constant.Male,
|
||||
CreateTime: uint32(time.Now().Unix()),
|
||||
Telephone: phoneNumber,
|
||||
Mobile: phoneNumber,
|
||||
Email: email,
|
||||
},
|
||||
OperationID: operationID,
|
||||
OpUserID: config.Config.Manager.AppManagerUid[0],
|
||||
IsRegister: false,
|
||||
}
|
||||
if strings.Contains("@", userID) {
|
||||
req.OrganizationUser.Email = userID
|
||||
} else {
|
||||
req.OrganizationUser.Telephone = userID
|
||||
}
|
||||
|
||||
resp, err := client.CreateOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||
|
||||
@@ -16,6 +16,7 @@ type resetPasswordRequest struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
NewPassword string `json:"newPassword" binding:"required"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
@@ -34,7 +35,7 @@ func ResetPassword(c *gin.Context) {
|
||||
account = req.PhoneNumber
|
||||
}
|
||||
if req.VerificationCode != config.Config.Demo.SuperCode {
|
||||
accountKey := account + "_" + constant.VerificationCodeForResetSuffix
|
||||
accountKey := req.AreaCode + account + "_" + constant.VerificationCodeForResetSuffix
|
||||
v, err := db.DB.GetAccountCode(accountKey)
|
||||
if err != nil || v != req.VerificationCode {
|
||||
log.NewError(req.OperationID, "password Verification code error", account, req.VerificationCode, v)
|
||||
@@ -42,7 +43,7 @@ func ResetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
user, err := im_mysql_model.GetRegister(account)
|
||||
user, err := im_mysql_model.GetRegister(account, req.AreaCode)
|
||||
if err != nil || user.Account == "" {
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
|
||||
|
||||
@@ -27,6 +27,7 @@ type paramsVerificationCode struct {
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
}
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
@@ -42,28 +43,28 @@ func SendVerificationCode(c *gin.Context) {
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
var accountKey string
|
||||
var accountKey = params.AreaCode + account
|
||||
if params.UsedFor == 0 {
|
||||
params.UsedFor = constant.VerificationCodeForRegister
|
||||
}
|
||||
switch params.UsedFor {
|
||||
case constant.VerificationCodeForRegister:
|
||||
_, err := im_mysql_model.GetRegister(account)
|
||||
_, err := im_mysql_model.GetRegister(account, params.AreaCode)
|
||||
if err == nil {
|
||||
log.NewError(params.OperationID, "The phone number has been registered", params)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
ok, err := db.DB.JudgeAccountEXISTS(account)
|
||||
ok, err := db.DB.JudgeAccountEXISTS(accountKey)
|
||||
if ok || err != nil {
|
||||
log.NewError(params.OperationID, "The phone number has been registered", params)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RepeatSendCode, "errMsg": "The phone number has been registered"})
|
||||
return
|
||||
}
|
||||
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
accountKey += "_" + constant.VerificationCodeForRegisterSuffix
|
||||
|
||||
case constant.VerificationCodeForReset:
|
||||
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
||||
accountKey += "_" + constant.VerificationCodeForResetSuffix
|
||||
}
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
code := 100000 + rand.Intn(900000)
|
||||
@@ -95,7 +96,7 @@ func SendVerificationCode(c *gin.Context) {
|
||||
}
|
||||
|
||||
sendSmsRequest := &dysmsapi20170525.SendSmsRequest{
|
||||
PhoneNumbers: tea.String(account),
|
||||
PhoneNumbers: tea.String(accountKey),
|
||||
SignName: tea.String(config.Config.Demo.AliSMSVerify.SignName),
|
||||
TemplateCode: tea.String(config.Config.Demo.AliSMSVerify.VerificationCodeTemplateCode),
|
||||
TemplateParam: tea.String(fmt.Sprintf("{\"code\":\"%d\"}", code)),
|
||||
|
||||
@@ -27,6 +27,7 @@ type ParamsSetPassword struct {
|
||||
Ex string `json:"ex"`
|
||||
FaceURL string `json:"faceURL"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
}
|
||||
|
||||
func SetPassword(c *gin.Context) {
|
||||
@@ -88,7 +89,7 @@ func SetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "begin store mysql", account, params.Password, "info", params.FaceURL, params.Nickname)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex, userID)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex, userID, params.AreaCode)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||
@@ -96,7 +97,7 @@ func SetPassword(c *gin.Context) {
|
||||
}
|
||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
||||
// demo onboarding
|
||||
onboardingProcess(params.OperationID, userID, params.Nickname, params.FaceURL)
|
||||
onboardingProcess(params.OperationID, userID, params.Nickname, params.FaceURL, params.AreaCode+params.PhoneNumber, params.Email)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ type paramsCertification struct {
|
||||
VerificationCode string `json:"verificationCode"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
AreaCode string `json:"areaCode"`
|
||||
}
|
||||
|
||||
func Verify(c *gin.Context) {
|
||||
@@ -31,7 +32,7 @@ func Verify(c *gin.Context) {
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
} else {
|
||||
account = params.PhoneNumber
|
||||
account = params.AreaCode + params.PhoneNumber
|
||||
}
|
||||
|
||||
if params.VerificationCode == config.Config.Demo.SuperCode {
|
||||
|
||||
+105
-14
@@ -258,7 +258,6 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
||||
|
||||
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.InviteUserToGroupReq) (*pbGroup.InviteUserToGroupResp, error) {
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||
|
||||
if !imdb.IsExistGroupMember(req.GroupID, req.OpUserID) && !token_verify.IsManagerUserID(req.OpUserID) {
|
||||
log.NewError(req.OperationID, "no permission InviteUserToGroup ", req.GroupID, req.OpUserID)
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
@@ -273,12 +272,45 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
errMsg := " group status is dismissed "
|
||||
return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrStatus.ErrCode, ErrMsg: errMsg}, nil
|
||||
}
|
||||
var resp pbGroup.InviteUserToGroupResp
|
||||
if groupInfo.NeedVerification == constant.AllNeedVerification &&
|
||||
!imdb.IsGroupOwnerAdmin(req.GroupID, req.OpUserID) && !token_verify.IsManagerUserID(req.OpUserID) {
|
||||
var resp pbGroup.InviteUserToGroupResp
|
||||
joinReq := pbGroup.JoinGroupReq{}
|
||||
for _, v := range req.InvitedUserIDList {
|
||||
var groupRequest db.GroupRequest
|
||||
groupRequest.UserID = v
|
||||
groupRequest.GroupID = req.GroupID
|
||||
err = imdb.InsertIntoGroupRequest(groupRequest)
|
||||
if err != nil {
|
||||
var resultNode pbGroup.Id2Result
|
||||
resultNode.Result = -1
|
||||
resultNode.UserID = v
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||
|
||||
continue
|
||||
log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
|
||||
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
} else {
|
||||
var resultNode pbGroup.Id2Result
|
||||
resultNode.Result = 0
|
||||
resultNode.UserID = v
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||
joinReq.GroupID = req.GroupID
|
||||
joinReq.OperationID = req.OperationID
|
||||
joinReq.OpUserID = v
|
||||
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||
chat.JoinGroupApplicationNotification(&joinReq)
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp)
|
||||
return &resp, nil
|
||||
}
|
||||
//
|
||||
//from User: invite: applicant
|
||||
//to user: invite: invited
|
||||
var okUserIDList []string
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
var resp pbGroup.InviteUserToGroupResp
|
||||
for _, v := range req.InvitedUserIDList {
|
||||
var resultNode pbGroup.Id2Result
|
||||
resultNode.UserID = v
|
||||
@@ -416,8 +448,8 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
}()
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ")
|
||||
return &pbGroup.InviteUserToGroupResp{}, nil
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp)
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
|
||||
@@ -836,26 +868,70 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrStatus.ErrCode, ErrMsg: errMsg}}, nil
|
||||
}
|
||||
|
||||
if groupInfo.NeedVerification == constant.Directly {
|
||||
us, err := imdb.GetUserByUserID(req.OpUserID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OpUserID)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
//to group member
|
||||
groupMember := db.GroupMember{GroupID: req.GroupID, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID}
|
||||
utils.CopyStructFields(&groupMember, us)
|
||||
err = imdb.InsertIntoGroupMember(groupMember)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if groupInfo.GroupType != constant.SuperGroup {
|
||||
addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{
|
||||
UserIDList: []string{req.OpUserID},
|
||||
GroupID: req.GroupID,
|
||||
OperationID: req.OperationID,
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: constant.ErrInternal.ErrMsg}}, nil
|
||||
}
|
||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
||||
cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error())
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
if cacheResp.CommonResp.ErrCode != 0 {
|
||||
log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String())
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
chat.MemberEnterDirectlyNotification(req.GroupID, req.OpUserID, req.OperationID)
|
||||
log.NewInfo(req.OperationID, "JoinGroup rpc return ")
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
} else {
|
||||
log.Error(req.OperationID, "JoinGroup rpc failed, group type: ", groupInfo.GroupType)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil
|
||||
}
|
||||
}
|
||||
|
||||
var groupRequest db.GroupRequest
|
||||
groupRequest.UserID = req.OpUserID
|
||||
groupRequest.ReqMsg = req.ReqMessage
|
||||
groupRequest.GroupID = req.GroupID
|
||||
|
||||
err = imdb.InsertIntoGroupRequest(groupRequest)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "UpdateGroupRequest ", err.Error(), groupRequest)
|
||||
log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||
}
|
||||
|
||||
_, err = imdb.GetGroupMemberListByGroupIDAndRoleLevel(req.GroupID, constant.GroupOwner)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupMemberListByGroupIDAndRoleLevel failed ", err.Error(), req.GroupID, constant.GroupOwner)
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
}
|
||||
//
|
||||
//_, err = imdb.GetGroupMemberListByGroupIDAndRoleLevel(req.GroupID, constant.GroupOwner)
|
||||
//if err != nil {
|
||||
// log.NewError(req.OperationID, "GetGroupMemberListByGroupIDAndRoleLevel failed ", err.Error(), req.GroupID, constant.GroupOwner)
|
||||
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
//}
|
||||
|
||||
chat.JoinGroupApplicationNotification(req)
|
||||
|
||||
log.NewInfo(req.OperationID, "ReceiveJoinApplicationNotification rpc return ")
|
||||
log.NewInfo(req.OperationID, "JoinGroup rpc return ")
|
||||
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
||||
}
|
||||
|
||||
@@ -1003,6 +1079,21 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
changedType = changedType | (1 << 3)
|
||||
faceURL = req.GroupInfo.FaceURL
|
||||
}
|
||||
|
||||
if req.GroupInfo.NeedVerification != nil {
|
||||
changedType = changedType | (1 << 4)
|
||||
m := make(map[string]interface{})
|
||||
m["need_verification"] = req.GroupInfo.NeedVerification.Value
|
||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfo.GroupID, m); err != nil {
|
||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//if req.RoleLevel != nil {
|
||||
//
|
||||
//}
|
||||
//only administrators can set group information
|
||||
var groupInfo db.Group
|
||||
utils.CopyStructFields(&groupInfo, req.GroupInfo)
|
||||
@@ -1013,7 +1104,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
||||
if changedType != 0 {
|
||||
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfo.GroupID, groupName, notification, introduction, faceURL)
|
||||
chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupInfo.GroupID, groupName, notification, introduction, faceURL, req.GroupInfo.NeedVerification)
|
||||
}
|
||||
if req.GroupInfo.Notification != "" {
|
||||
//get group member user id
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
//message GroupCreatedTips{
|
||||
@@ -231,7 +232,7 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL
|
||||
// notification := ""
|
||||
// introduction := ""
|
||||
// faceURL := ""
|
||||
func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string) {
|
||||
func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) {
|
||||
GroupInfoChangedTips := open_im_sdk.GroupInfoSetTips{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)
|
||||
@@ -241,6 +242,8 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName,
|
||||
GroupInfoChangedTips.Group.Notification = notification
|
||||
GroupInfoChangedTips.Group.Introduction = introduction
|
||||
GroupInfoChangedTips.Group.FaceURL = faceURL
|
||||
GroupInfoChangedTips.Group.NeedVerification = needVerification
|
||||
|
||||
if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
return
|
||||
@@ -553,9 +556,21 @@ func MemberEnterNotification(req *pbGroup.GroupApplicationResponseReq) {
|
||||
return
|
||||
}
|
||||
if err := setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil {
|
||||
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser)
|
||||
log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser)
|
||||
return
|
||||
}
|
||||
groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID)
|
||||
|
||||
}
|
||||
|
||||
func MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) {
|
||||
MemberEnterTips := open_im_sdk.MemberEnterTips{Group: &open_im_sdk.GroupInfo{}, EntrantUser: &open_im_sdk.GroupMemberFullInfo{}}
|
||||
if err := setGroupInfo(groupID, MemberEnterTips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group)
|
||||
return
|
||||
}
|
||||
if err := setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser)
|
||||
return
|
||||
}
|
||||
groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user