mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
This commit is contained in:
@@ -21,7 +21,7 @@ type ImportFriendReq struct {
|
||||
FromUserID string `json:"fromUserID" binding:"required"`
|
||||
}
|
||||
type UserIDResult struct {
|
||||
UserID string `json:"userID""`
|
||||
UserID string `json:"userID"`
|
||||
Result int32 `json:"result"`
|
||||
}
|
||||
type ImportFriendResp struct {
|
||||
|
||||
@@ -185,3 +185,38 @@ type DismissGroupReq struct {
|
||||
type DismissGroupResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type MuteGroupMemberReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
MutedSeconds uint32 `json:"mutedSeconds" binding:"required"`
|
||||
}
|
||||
type MuteGroupMemberResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type CancelMuteGroupMemberReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
}
|
||||
type CancelMuteGroupMemberResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type MuteGroupReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
}
|
||||
type MuteGroupResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type CancelMuteGroupReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
}
|
||||
type CancelMuteGroupResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package base_info
|
||||
|
||||
type OSSCredentialReq struct {
|
||||
OperationID string `json:"operationID"`
|
||||
Filename string `json:"filename"`
|
||||
FileType string `json:"file_type"`
|
||||
}
|
||||
|
||||
type OSSCredentialRespData struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
AccessKeyId string `json:"access_key_id"`
|
||||
AccessKeySecret string `json:"access_key_secret"`
|
||||
Token string `json:"token"`
|
||||
Bucket string `json:"bucket"`
|
||||
FinalHost string `json:"final_host"`
|
||||
}
|
||||
|
||||
type OSSCredentialResp struct {
|
||||
CommResp
|
||||
OssData OSSCredentialRespData `json:"-"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
}
|
||||
@@ -45,6 +45,17 @@ type config struct {
|
||||
SecretID string `yaml:"secretID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
Ali struct {
|
||||
RegionID string `yaml:"regionID"`
|
||||
AccessKeyID string `yaml:"accessKeyID"`
|
||||
AccessKeySecret string `yaml:"accessKeySecret"`
|
||||
StsEndpoint string `yaml:"stsEndpoint"`
|
||||
OssEndpoint string `yaml:"ossEndpoint"`
|
||||
Bucket string `yaml:"bucket"`
|
||||
FinalHost string `yaml:"finalHost"`
|
||||
StsDurationSeconds int64 `yaml:"stsDurationSeconds"`
|
||||
OssRoleArn string `yaml:"OssRoleArn"`
|
||||
}
|
||||
Minio struct {
|
||||
Bucket string `yaml:"bucket"`
|
||||
Location string `yaml:"location"`
|
||||
@@ -66,6 +77,7 @@ type config struct {
|
||||
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
||||
}
|
||||
Mongo struct {
|
||||
DBUri string `yaml:"dbUri"` // 当dbUri值不为空则直接使用该值
|
||||
DBAddress []string `yaml:"dbAddress"`
|
||||
DBDirect bool `yaml:"dbDirect"`
|
||||
DBTimeout int `yaml:"dbTimeout"`
|
||||
|
||||
@@ -79,6 +79,7 @@ const (
|
||||
MemberInvitedNotification = 1509
|
||||
MemberEnterNotification = 1510
|
||||
GroupDismissedNotification = 1511
|
||||
GroupMemberInfoChangedNotification = 1512
|
||||
|
||||
SignalingNotificationBegin = 1600
|
||||
SignalingNotification = 1601
|
||||
@@ -138,6 +139,7 @@ const (
|
||||
GroupOk = 0
|
||||
GroupBanChat = 1
|
||||
GroupStatusDismissed = 2
|
||||
GroupStatusMuted = 3
|
||||
|
||||
GroupBaned = 3
|
||||
GroupBanPrivateChat = 4
|
||||
|
||||
@@ -41,12 +41,17 @@ func init() {
|
||||
// mongo init
|
||||
// "mongodb://sysop:moon@localhost/records"
|
||||
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?connect=direct&maxPoolSize=%d",
|
||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
if config.Config.Mongo.DBUri != "" {
|
||||
// example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
|
||||
uri = config.Config.Mongo.DBUri
|
||||
} else {
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
}
|
||||
|
||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
if err != nil{
|
||||
log.NewError(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
|
||||
time.Sleep(time.Duration(30) * time.Second)
|
||||
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
|
||||
@@ -30,6 +30,9 @@ func InsertIntoGroupMember(toInsertInfo db.GroupMember) error {
|
||||
if toInsertInfo.RoleLevel == 0 {
|
||||
toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
|
||||
}
|
||||
if toInsertInfo.MuteEndTime.Unix() == 0 {
|
||||
toInsertInfo.MuteEndTime = time.Unix(0, 0)
|
||||
}
|
||||
err = dbConn.Table("group_members").Create(toInsertInfo).Error
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -281,6 +284,14 @@ func GetGroupMembersCount(groupId, userName string) (int32, error) {
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func UpdateGroupMemberInfoDefaultZero(groupMemberInfo db.GroupMember, args map[string]interface{}) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return dbConn.Model(groupMemberInfo).Updates(args).Error
|
||||
}
|
||||
|
||||
//
|
||||
//func SelectGroupList(groupID string) ([]string, error) {
|
||||
// var groupUserID string
|
||||
|
||||
@@ -57,7 +57,6 @@ func SetGroupInfo(groupInfo db.Group) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
err = dbConn.Table("groups").Where("group_id=?", groupInfo.GroupID).Update(&groupInfo).Error
|
||||
return err
|
||||
}
|
||||
@@ -68,7 +67,7 @@ func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]db.Group
|
||||
if err != nil {
|
||||
return groups, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
|
||||
err = dbConn.Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", groupName)).Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error
|
||||
return groups, err
|
||||
}
|
||||
@@ -79,7 +78,7 @@ func GetGroups(pageNumber, showNumber int) ([]db.Group, error) {
|
||||
if err != nil {
|
||||
return groups, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
|
||||
if err = dbConn.Table("groups").Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error; err != nil {
|
||||
return groups, err
|
||||
}
|
||||
@@ -102,7 +101,7 @@ func DeleteGroup(groupId string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
|
||||
var group db.Group
|
||||
var groupMembers []db.GroupMember
|
||||
if err := dbConn.Table("groups").Where("group_id=?", groupId).Delete(&group).Error; err != nil {
|
||||
@@ -119,7 +118,6 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) (string, string,
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
groupMember := db.GroupMember{
|
||||
UserID: userId,
|
||||
GroupID: groupId,
|
||||
@@ -182,7 +180,7 @@ func GetGroupsCountNum(group db.Group) (int32, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
|
||||
var count int32
|
||||
if err := dbConn.Table("groups").Where(fmt.Sprintf(" name like '%%%s%%' ", group.GroupName)).Count(&count).Error; err != nil {
|
||||
return 0, err
|
||||
@@ -198,7 +196,7 @@ func GetGroupById(groupId string) (db.Group, error) {
|
||||
if err != nil {
|
||||
return group, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
|
||||
if err := dbConn.Table("groups").Find(&group).Error; err != nil {
|
||||
return group, err
|
||||
}
|
||||
@@ -211,9 +209,17 @@ func GetGroupMaster(groupId string) (db.GroupMember, error) {
|
||||
if err != nil {
|
||||
return groupMember, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
|
||||
if err := dbConn.Table("group_members").Where("role_level=? and group_id=?", constant.GroupOwner, groupId).Find(&groupMember).Error; err != nil {
|
||||
return groupMember, err
|
||||
}
|
||||
return groupMember, nil
|
||||
}
|
||||
|
||||
func UpdateGroupInfoDefaultZero(groupInfo db.Group, args map[string]interface{}) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return dbConn.Model(groupInfo).Updates(args).Error
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ func GroupMemberDBCopyOpenIM(dst *open_im_sdk.GroupMemberFullInfo, src *db.Group
|
||||
dst.AppMangerLevel = 1
|
||||
}
|
||||
dst.JoinTime = int32(src.JoinTime.Unix())
|
||||
dst.MuteEndTime = uint32(src.JoinTime.Unix())
|
||||
if dst.MuteEndTime < uint32(time.Now().Unix()) {
|
||||
dst.MuteEndTime = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+720
-178
File diff suppressed because it is too large
Load Diff
@@ -319,7 +319,7 @@ message AddGroupMembersCMSResp {
|
||||
}
|
||||
|
||||
message DismissGroupReq{
|
||||
string opUserID = 1; //group member or app manager
|
||||
string opUserID = 1; //group or app manager
|
||||
string operationID = 2;
|
||||
string groupID = 3;
|
||||
}
|
||||
@@ -328,6 +328,59 @@ message DismissGroupResp{
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
|
||||
message MuteGroupMemberReq{
|
||||
string opUserID = 1; //group or app manager
|
||||
string operationID = 2;
|
||||
string groupID = 3;
|
||||
string userID = 4;
|
||||
uint32 mutedSeconds = 5;
|
||||
}
|
||||
|
||||
message MuteGroupMemberResp{
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
message CancelMuteGroupMemberReq{
|
||||
string opUserID = 1; //group or app manager
|
||||
string operationID = 2;
|
||||
string groupID = 3;
|
||||
string userID = 4;
|
||||
}
|
||||
|
||||
message CancelMuteGroupMemberResp{
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
|
||||
message MuteGroupReq{
|
||||
string opUserID = 1; //group or app manager
|
||||
string operationID = 2;
|
||||
string groupID = 3;
|
||||
}
|
||||
|
||||
message MuteGroupResp{
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
message CancelMuteGroupReq{
|
||||
string opUserID = 1; //group or app manager
|
||||
string operationID = 2;
|
||||
string groupID = 3;
|
||||
}
|
||||
|
||||
message CancelMuteGroupResp{
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
service group{
|
||||
rpc createGroup(CreateGroupReq) returns(CreateGroupResp);
|
||||
rpc joinGroup(JoinGroupReq) returns(JoinGroupResp);
|
||||
@@ -356,6 +409,10 @@ service group{
|
||||
rpc AddGroupMembersCMS(AddGroupMembersCMSReq) returns(AddGroupMembersCMSResp);
|
||||
|
||||
rpc DismissGroup(DismissGroupReq) returns(DismissGroupResp);
|
||||
rpc MuteGroupMember(MuteGroupMemberReq) returns(MuteGroupMemberResp);
|
||||
rpc CancelMuteGroupMember(CancelMuteGroupMemberReq) returns(CancelMuteGroupMemberResp);
|
||||
rpc MuteGroup(MuteGroupReq) returns(MuteGroupResp);
|
||||
rpc CancelMuteGroup(CancelMuteGroupReq) returns(CancelMuteGroupResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+482
-224
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ message GroupMemberFullInfo {
|
||||
int32 joinSource = 8;
|
||||
string operatorUserID = 9;
|
||||
string ex = 10;
|
||||
uint32 muteEndTime = 11;
|
||||
}
|
||||
|
||||
message PublicUserInfo{
|
||||
@@ -260,6 +261,33 @@ message GroupDismissedTips{
|
||||
int64 operationTime = 3;
|
||||
}
|
||||
|
||||
message GroupMemberMutedTips{
|
||||
GroupInfo group = 1;
|
||||
GroupMemberFullInfo opUser = 2;
|
||||
int64 operationTime = 3;
|
||||
GroupMemberFullInfo mutedUser = 4;
|
||||
uint32 mutedSeconds = 5;
|
||||
}
|
||||
|
||||
message GroupMemberCancelMutedTips{
|
||||
GroupInfo group = 1;
|
||||
GroupMemberFullInfo opUser = 2;
|
||||
int64 operationTime = 3;
|
||||
GroupMemberFullInfo mutedUser = 4;
|
||||
}
|
||||
|
||||
message GroupMutedTips{
|
||||
GroupInfo group = 1;
|
||||
GroupMemberFullInfo opUser = 2;
|
||||
int64 operationTime = 3;
|
||||
}
|
||||
|
||||
message GroupCancelMutedTips{
|
||||
GroupInfo group = 1;
|
||||
GroupMemberFullInfo opUser = 2;
|
||||
int64 operationTime = 3;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////friend/////////////////////
|
||||
//message FriendInfo{
|
||||
|
||||
Reference in New Issue
Block a user