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

View File

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

View File

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

View File

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

View File

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

View File

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