Merge remote-tracking branch 'origin/superGroup' into superGroup

This commit is contained in:
Gordon 2022-06-17 12:39:58 +08:00
commit 87e6aedb74
6 changed files with 27 additions and 17 deletions

View File

@ -222,6 +222,7 @@ manager:
#app管理员userID和对应的secret 建议修改。 用于管理后台登录也可以用户管理后台对应的api
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
appSysNotificationName: "系统通知"
secret: tuoyun
# 多端互踢策略

View File

@ -261,7 +261,7 @@ func randomEnglishName() string {
}
func randomPosition() string {
l := []string{"Golang工程师", "前端工程师", "后端工程师", "产品经理", "测试开发工程师", "运维开发工程师"}
l := []string{"后端工程师", "前端工程师", "设计师"}
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(l) - 1)
return l[index]

View File

@ -117,15 +117,19 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
var nickname string
if utils.IsContain(sendID, config.Config.Manager.AppManagerUid) {
nickname = sendID
} else {
from, err := imdb.GetUserByUserID(sendID)
if err != nil {
log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID)
}
if from != nil {
nickname = from.Nickname
}
}
from, err := imdb.GetUserByUserID(sendID)
if err != nil {
log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID)
}
nickname := ""
if from != nil {
nickname = from.Nickname
}
to, err := imdb.GetUserByUserID(recvUserID)
if err != nil {
log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID)

View File

@ -191,8 +191,9 @@ type config struct {
}
}
Manager struct {
AppManagerUid []string `yaml:"appManagerUid"`
Secrets []string `yaml:"secrets"`
AppManagerUid []string `yaml:"appManagerUid"`
Secrets []string `yaml:"secrets"`
AppSysNotificationName string `yaml:"appSysNotificationName"`
}
Kafka struct {

View File

@ -22,7 +22,11 @@ func init() {
}
var appMgr db.User
appMgr.UserID = v
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
if k == 0 {
appMgr.Nickname = config.Config.Manager.AppSysNotificationName
} else {
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
}
appMgr.AppMangerLevel = constant.AppAdmin
err = UserRegister(appMgr)
if err != nil {

View File

@ -83,9 +83,9 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
select {
case pv, ok := <-kresp:
if ok == true {
log.Debug(operationID, "KeepAlive kresp ok", pv)
log.Debug(operationID, "KeepAlive kresp ok", pv, args)
} else {
log.Error(operationID, "KeepAlive kresp failed", pv)
log.Error(operationID, "KeepAlive kresp failed ", pv, args)
t := time.NewTicker(time.Duration(ttl/2) * time.Second)
for {
select {
@ -94,15 +94,15 @@ func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName strin
ctx, _ := context.WithCancel(context.Background())
resp, err := cli.Grant(ctx, int64(ttl))
if err != nil {
log.Error(operationID, "Grant failed ", err.Error())
log.Error(operationID, "Grant failed ", err.Error(), args)
continue
}
if _, err := cli.Put(ctx, serviceKey, serviceValue, clientv3.WithLease(resp.ID)); err != nil {
log.Error(operationID, "etcd Put failed ", err.Error(), args, "resp ID: ", resp.ID)
log.Error(operationID, "etcd Put failed ", err.Error(), args, " resp ID: ", resp.ID)
continue
} else {
log.Info(operationID, "etcd Put ok ", args, "resp ID: ", resp.ID)
log.Info(operationID, "etcd Put ok ", args, " resp ID: ", resp.ID)
}
}
}