mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Create group extension field
This commit is contained in:
parent
13038514df
commit
8b156dc962
@ -18,6 +18,7 @@ type paramsCreateGroupStruct struct {
|
||||
Notification string `json:"notification"`
|
||||
FaceUrl string `json:"faceUrl"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Ex string `json:"ex"`
|
||||
}
|
||||
|
||||
func CreateGroup(c *gin.Context) {
|
||||
@ -39,6 +40,7 @@ func CreateGroup(c *gin.Context) {
|
||||
Notification: params.Notification,
|
||||
FaceUrl: params.FaceUrl,
|
||||
OperationID: params.OperationID,
|
||||
Ex: params.Ex,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api create group is server,params=%s", req.String())
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func InsertIntoGroup(groupId, name, introduction, notification, faceUrl string) error {
|
||||
func InsertIntoGroup(groupId, name, introduction, notification, faceUrl, ex string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -17,7 +17,7 @@ func InsertIntoGroup(groupId, name, introduction, notification, faceUrl string)
|
||||
if name == "" {
|
||||
name = "groupChat"
|
||||
}
|
||||
toInsertInfo := Group{GroupId: groupId, Name: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now()}
|
||||
toInsertInfo := Group{GroupId: groupId, Name: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now(), Ex: ex}
|
||||
err = dbConn.Table("group").Create(toInsertInfo).Error
|
||||
if err != nil {
|
||||
return err
|
||||
@ -194,6 +194,7 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
|
||||
|
||||
ownerUser, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OwnerID)
|
||||
if err != nil {
|
||||
log.ErrorByKv("FindGroupMemberInfoByGroupIdAndUserId failed", pb.OperationID, "groupId", pb.GroupID, "ownerID", pb.OwnerID)
|
||||
return nil, err
|
||||
}
|
||||
if ownerUser.AdministratorLevel <= 0 {
|
||||
@ -208,6 +209,7 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
|
||||
err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and from_user_id = ? and to_user_id = ?",
|
||||
"", pb.GroupID, pb.FromUserID, pb.ToUserID).Scan(&groupRequest).Error
|
||||
if err != nil {
|
||||
log.ErrorByKv("find group_request info failed", pb.OperationID, "groupId", pb.GroupID, "fromUserId", pb.FromUserID, "toUserId", pb.OwnerID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -226,6 +228,7 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
|
||||
err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and from_user_id = ? and to_user_id = ?",
|
||||
saveFlag, pb.HandledMsg, pb.OwnerID, groupRequest.GroupID, groupRequest.FromUserID, groupRequest.ToUserID).Error
|
||||
if err != nil {
|
||||
log.ErrorByKv("update group request failed", pb.OperationID, "groupID", pb.GroupID, "flag", saveFlag, "ownerId", pb.OwnerID, "fromUserId", pb.FromUserID, "toUserID", pb.ToUserID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -233,11 +236,13 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
|
||||
if groupRequest.ToUserID == "0" {
|
||||
err = InsertIntoGroupMember(pb.GroupID, pb.FromUserID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0)
|
||||
if err != nil {
|
||||
log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err = InsertIntoGroupMember(pb.GroupID, pb.ToUserID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0)
|
||||
if err != nil {
|
||||
log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ message CreateGroupReq{
|
||||
string faceUrl = 5;
|
||||
string token = 6;
|
||||
string operationID = 7;
|
||||
|
||||
string ex = 8;
|
||||
}
|
||||
message GroupAddMemberInfo{
|
||||
string uid = 1;
|
||||
|
@ -76,7 +76,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
}
|
||||
//Time stamp + MD5 to generate group chat id
|
||||
groupId = utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10))
|
||||
err = im_mysql_model.InsertIntoGroup(groupId, req.GroupName, req.Introduction, req.Notification, req.FaceUrl)
|
||||
err = im_mysql_model.InsertIntoGroup(groupId, req.GroupName, req.Introduction, req.Notification, req.FaceUrl, req.Ex)
|
||||
if err != nil {
|
||||
log.ErrorByKv("create group chat failed", req.OperationID, "err=%s", err.Error())
|
||||
return &pbGroup.CreateGroupResp{ErrorCode: config.ErrCreateGroup.ErrCode, ErrorMsg: config.ErrCreateGroup.ErrMsg}, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user