mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 04:55:59 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
# Conflicts: # cmd/Open-IM-SDK-Core # pkg/common/config/config.go
This commit is contained in:
@@ -3,8 +3,12 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -205,7 +209,18 @@ func init() {
|
||||
//bytes, err := ioutil.ReadFile(path + "/config/config.yaml")
|
||||
// if we cd Open-IM-Server/src/utils and run go test
|
||||
// it will panic cannot find config/config.yaml
|
||||
bytes, err := ioutil.ReadFile(Root + "/config/config.yaml")
|
||||
|
||||
cfgName := os.Getenv("CONFIG_NAME")
|
||||
if len(cfgName) == 0 {
|
||||
cfgName = Root + "/config/config.yaml"
|
||||
}
|
||||
|
||||
viper.SetConfigFile(cfgName)
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
bytes, err := ioutil.ReadFile(cfgName)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ const (
|
||||
Revoke = 205
|
||||
C2CMessageAsRead = 206
|
||||
|
||||
KickOnlineTip = 303
|
||||
|
||||
TransferGroupOwnerTip = 501
|
||||
CreateGroupTip = 502
|
||||
GroupApplicationResponseTip = 503
|
||||
@@ -89,6 +87,8 @@ const (
|
||||
|
||||
OnlineStatus = "online"
|
||||
OfflineStatus = "offline"
|
||||
Registered = "registered"
|
||||
UnRegistered = "unregistered"
|
||||
|
||||
//MsgReceiveOpt
|
||||
ReceiveMessage = 0
|
||||
|
||||
@@ -133,6 +133,25 @@ func SelectAllUID() ([]string, error) {
|
||||
}
|
||||
return uid, nil
|
||||
}
|
||||
func SelectSomeUID(uids []string) ([]string, error) {
|
||||
var uid []string
|
||||
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return uid, err
|
||||
}
|
||||
rows, err := dbConn.Raw("select uid from user where uid in (" + sqlStringHandle(uids) + ")").Rows()
|
||||
if err != nil {
|
||||
return uid, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var strUID string
|
||||
for rows.Next() {
|
||||
rows.Scan(&strUID)
|
||||
uid = append(uid, strUID)
|
||||
}
|
||||
return uid, nil
|
||||
}
|
||||
|
||||
func IsExistUser(uid string) bool {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
@@ -149,3 +168,12 @@ func IsExistUser(uid string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func sqlStringHandle(ss []string) (s string) {
|
||||
for i := 0; i < len(ss); i++ {
|
||||
s += "'" + ss[i] + "'"
|
||||
if i < len(ss)-1 {
|
||||
s += ","
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user