parent
12dd42c60d
commit
01d3fefd5d
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="grafana" uuid="95aae14a-3593-4ff7-ab49-5e4316cbecd1">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:C:\Users\Administrator\Desktop\Open-IM-Server\docker-compose_cfg\grafana.db</jdbc-url>
|
||||
<driver-properties>
|
||||
<property name="enable_load_extension" value="true" />
|
||||
</driver-properties>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Open-IM-Server.iml" filepath="$PROJECT_DIR$/.idea/Open-IM-Server.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,59 +0,0 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
mongo2 "Open_IM/test/mongo"
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
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 {
|
||||
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
|
||||
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
|
||||
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
|
||||
} else {
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
}
|
||||
}
|
||||
var err error
|
||||
mongo2.Client, err = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = mongo2.Client.Ping(context.TODO(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("Connected to MongoDB!")
|
||||
}
|
||||
|
||||
func main() {
|
||||
userID := flag.String("userID", "", "userID")
|
||||
flag.Parse()
|
||||
fmt.Println("userID:", *userID)
|
||||
mongo2.GetUserAllChat(*userID)
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
Client *mongo.Client
|
||||
)
|
||||
|
||||
type MsgInfo struct {
|
||||
SendTime int64
|
||||
Msg []byte
|
||||
}
|
||||
|
||||
type UserChat struct {
|
||||
UID string
|
||||
Msg []MsgInfo
|
||||
}
|
||||
|
||||
func GetUserAllChat(uid string) {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||
collection := Client.Database(config.Config.Mongo.DBDatabase).Collection("msg")
|
||||
var userChatList []UserChat
|
||||
uid = uid + ":"
|
||||
filter := bson.M{"uid": bson.M{"$regex": uid}}
|
||||
//filter := bson.M{"uid": "17726378428:0"}
|
||||
result, err := collection.Find(context.Background(), filter)
|
||||
if err != nil {
|
||||
fmt.Println("find error", err.Error())
|
||||
return
|
||||
}
|
||||
if err := result.All(ctx, &userChatList); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
for _, userChat := range userChatList {
|
||||
for _, msg := range userChat.Msg {
|
||||
msgData := &server_api_params.MsgData{}
|
||||
err := proto.Unmarshal(msg.Msg, msgData)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error(), msg)
|
||||
continue
|
||||
}
|
||||
fmt.Println("seq: ", msgData.Seq, "status: ", msgData.Status,
|
||||
"sendID: ", msgData.SendID, "recvID: ", msgData.RecvID,
|
||||
"sendTime: ", msgData.SendTime,
|
||||
"clientMsgID: ", msgData.ClientMsgID,
|
||||
"serverMsgID: ", msgData.ServerMsgID,
|
||||
"content: ", string(msgData.Content))
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/test/mysql"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mysql.ImportUserToSuperGroup()
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ImportUserToSuperGroup() {
|
||||
for i := 18000000700; i <= 18000000800; i++ {
|
||||
user := db.User{
|
||||
UserID: strconv.Itoa(i),
|
||||
Nickname: strconv.Itoa(i),
|
||||
FaceURL: "",
|
||||
Gender: 0,
|
||||
PhoneNumber: strconv.Itoa(i),
|
||||
Birth: time.Time{},
|
||||
Email: "",
|
||||
Ex: "",
|
||||
CreateTime: time.Time{},
|
||||
AppMangerLevel: 0,
|
||||
GlobalRecvMsgOpt: 0,
|
||||
}
|
||||
err := im_mysql_model.UserRegister(user)
|
||||
if err != nil {
|
||||
log.NewError("", err.Error(), user)
|
||||
continue
|
||||
}
|
||||
|
||||
groupMember := db.GroupMember{
|
||||
GroupID: "3907826375",
|
||||
UserID: strconv.Itoa(i),
|
||||
Nickname: strconv.Itoa(i),
|
||||
FaceURL: "",
|
||||
RoleLevel: 0,
|
||||
JoinTime: time.Time{},
|
||||
JoinSource: 0,
|
||||
InviterUserID: "openIMAdmin",
|
||||
OperatorUserID: "openIMAdmin",
|
||||
MuteEndTime: time.Time{},
|
||||
Ex: "",
|
||||
}
|
||||
|
||||
err = im_mysql_model.InsertIntoGroupMember(groupMember)
|
||||
if err != nil {
|
||||
log.NewError("", err.Error(), user)
|
||||
continue
|
||||
}
|
||||
|
||||
log.NewInfo("success", i)
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue