mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
tidy code
This commit is contained in:
parent
39ceb20332
commit
47a3c3c253
@ -94,7 +94,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
}
|
||||
|
||||
//to group member
|
||||
groupMember := imdb.GroupMember{GroupID: groupId, RoleLevel: 1}
|
||||
groupMember := imdb.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner}
|
||||
utils.CopyStructFields(&groupMember, us)
|
||||
err = im_mysql_model.InsertIntoGroupMember(groupMember)
|
||||
if err != nil {
|
||||
@ -114,7 +114,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
log.NewError(req.OperationID, "FindUserByUID failed ", err.Error(), user.UserID)
|
||||
continue
|
||||
}
|
||||
if user.RoleLevel == 1 {
|
||||
if user.RoleLevel == constant.GroupOwner {
|
||||
log.NewError(req.OperationID, "only one owner, failed ", user)
|
||||
continue
|
||||
}
|
||||
@ -224,7 +224,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
var toInsertInfo imdb.GroupMember
|
||||
utils.CopyStructFields(&toInsertInfo, toUserInfo)
|
||||
toInsertInfo.GroupID = req.GroupID
|
||||
toInsertInfo.RoleLevel = 0
|
||||
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
||||
err = imdb.InsertIntoGroupMember(toInsertInfo)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", req.GroupID, toUserInfo.UserID, toUserInfo.Nickname, toUserInfo.FaceUrl)
|
||||
@ -331,7 +331,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
|
||||
groupOwnerUserID := ""
|
||||
for _, v := range ownerList {
|
||||
if v.RoleLevel == 1 {
|
||||
if v.RoleLevel == constant.GroupOwner {
|
||||
groupOwnerUserID = v.UserID
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ package constant
|
||||
const (
|
||||
|
||||
//group admin
|
||||
OrdinaryMember = 0
|
||||
GroupOwner = 1
|
||||
Administrator = 2
|
||||
// OrdinaryMember = 0
|
||||
// GroupOwner = 1
|
||||
// Administrator = 2
|
||||
//group application
|
||||
Application = 0
|
||||
AgreeApplication = 1
|
||||
// Application = 0
|
||||
// AgreeApplication = 1
|
||||
|
||||
//friend related
|
||||
BlackListFlag = 1
|
||||
@ -117,4 +117,16 @@ var ContentType2PushContent = map[int64]string{
|
||||
Common: "你收到一条新消息",
|
||||
}
|
||||
|
||||
const (
|
||||
AppOrdinaryUsers = 1
|
||||
AppAdmin = 2
|
||||
|
||||
GroupOrdinaryUsers = 1
|
||||
GroupOwner = 2
|
||||
GroupAdmin = 3
|
||||
|
||||
Male = 1
|
||||
Female = 2
|
||||
)
|
||||
|
||||
const FriendAcceptTip = "You have successfully become friends, so start chatting"
|
||||
|
@ -1,6 +1,7 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
@ -23,6 +24,9 @@ func InsertIntoGroupMember(toInsertInfo GroupMember) error {
|
||||
return err
|
||||
}
|
||||
toInsertInfo.JoinSource = time.Now()
|
||||
if toInsertInfo.RoleLevel == 0 {
|
||||
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
||||
}
|
||||
err = dbConn.Table("group_member").Create(toInsertInfo).Error
|
||||
if err != nil {
|
||||
return err
|
||||
@ -138,7 +142,7 @@ func GetGroupOwnerInfoByGroupID(groupID string) (*GroupMember, error) {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range omList {
|
||||
if v.RoleLevel == 1 {
|
||||
if v.RoleLevel == constant.GroupOwner {
|
||||
return &v, nil
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
@ -88,7 +89,7 @@ func GetGroupApplicationList(userID string) ([]GroupRequest, error) {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range memberList {
|
||||
if v.RoleLevel > 0 {
|
||||
if v.RoleLevel > constant.GroupOrdinaryUsers {
|
||||
list, err := GetGroupRequestByGroupID(v.GroupID)
|
||||
if err != nil {
|
||||
continue
|
||||
|
@ -2,6 +2,7 @@ package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/utils"
|
||||
"fmt"
|
||||
@ -15,13 +16,13 @@ func init() {
|
||||
user, err := GetUserByUserID(v)
|
||||
if err != nil {
|
||||
fmt.Println("GetUserByUserID failed ", err.Error(), v, user)
|
||||
}else{
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
var appMgr User
|
||||
appMgr.UserID = v
|
||||
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
|
||||
appMgr.AppMangerLevel = 2
|
||||
appMgr.AppMangerLevel = constant.AppAdmin
|
||||
err = UserRegister(appMgr)
|
||||
if err != nil {
|
||||
fmt.Println("AppManager insert error", err.Error())
|
||||
@ -36,7 +37,9 @@ func UserRegister(user User) error {
|
||||
return err
|
||||
}
|
||||
user.CreateTime = time.Now()
|
||||
|
||||
if user.AppMangerLevel == 0 {
|
||||
user.AppMangerLevel = constant.AppOrdinaryUsers
|
||||
}
|
||||
err = dbConn.Table("user").Create(&user).Error
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user