mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 03:25:59 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -2,6 +2,7 @@ package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -65,11 +66,12 @@ func UpdateFriendApplication(friendRequest *FriendRequest) error {
|
||||
return err
|
||||
}
|
||||
friendRequest.CreateTime = time.Now()
|
||||
err = dbConn.Table("friend_request").Where("from_user_id=? and to_user_id=?", friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest).Error
|
||||
if err != nil {
|
||||
return err
|
||||
if dbConn.Table("friend_request").Where("from_user_id=? and to_user_id=?",
|
||||
friendRequest.FromUserID, friendRequest.ToUserID).Update(&friendRequest).RowsAffected == 0 {
|
||||
return InsertFriendApplication(friendRequest)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func InsertFriendApplication(friendRequest *FriendRequest) error {
|
||||
@@ -77,6 +79,12 @@ func InsertFriendApplication(friendRequest *FriendRequest) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if friendRequest.CreateTime.Unix() < 0 {
|
||||
friendRequest.CreateTime = time.Now()
|
||||
}
|
||||
if friendRequest.HandleTime.Unix() < 0 {
|
||||
friendRequest.HandleTime = utils.UnixSecondToTime(0)
|
||||
}
|
||||
err = dbConn.Table("friend_request").Create(friendRequest).Error
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
@@ -22,7 +23,10 @@ func InsertIntoGroupMember(toInsertInfo GroupMember) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
toInsertInfo.JoinSource = time.Now()
|
||||
toInsertInfo.JoinTime = 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
|
||||
|
||||
@@ -95,7 +95,7 @@ type GroupMember struct {
|
||||
JoinTime time.Time `gorm:"column:join_time"`
|
||||
Nickname string `gorm:"column:nickname"`
|
||||
FaceUrl string `gorm:"user_group_face_url"`
|
||||
JoinSource time.Time `gorm:"column:join_source"`
|
||||
JoinSource int32 `gorm:"column:join_source"`
|
||||
OperatorUserID string `gorm:"column:operator_user_id"`
|
||||
Ex string `gorm:"column:ex"`
|
||||
}
|
||||
|
||||
@@ -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,16 @@ func init() {
|
||||
user, err := GetUserByUserID(v)
|
||||
if err != nil {
|
||||
fmt.Println("GetUserByUserID failed ", err.Error(), v, user)
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
var appMgr User
|
||||
appMgr.UserID = v
|
||||
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
|
||||
appMgr.AppMangerLevel = constant.AppAdmin
|
||||
err = UserRegister(appMgr)
|
||||
if err != nil {
|
||||
fmt.Println("AppManager insert error", err.Error())
|
||||
fmt.Println("AppManager insert error", err.Error(), appMgr, "time: ", appMgr.Birth.Unix())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +37,12 @@ func UserRegister(user User) error {
|
||||
return err
|
||||
}
|
||||
user.CreateTime = time.Now()
|
||||
|
||||
if user.AppMangerLevel == 0 {
|
||||
user.AppMangerLevel = constant.AppOrdinaryUsers
|
||||
}
|
||||
if user.Birth.Unix() < 0 {
|
||||
user.Birth = utils.UnixSecondToTime(0)
|
||||
}
|
||||
err = dbConn.Table("user").Create(&user).Error
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user