Compare commits

..

No commits in common. "f9921d2ba0d25a2f67b0d57b6079bb744f307e20" and "f3e0ae8672fc65d6e9ca01ea3014f62513384e5c" have entirely different histories.

3 changed files with 29 additions and 41 deletions

View File

@ -191,14 +191,12 @@ func (o *ChatRoom) Register(c *Client) (sessionId string) {
// msgType 消息类型 // msgType 消息类型
// message: 消息内容 // message: 消息内容
func (o *ChatRoom) SendSessionMessage(chatUser *accountFiee.ChatUserData, sessionId string, msgType WsType, message any) (userIdInSession []int64, err error) { func (o *ChatRoom) SendSessionMessage(chatUser *accountFiee.ChatUserData, sessionId string, msgType WsType, message any) (userIdInSession []int64, err error) {
fmt.Println("ChatRoom.SendSessionMessage ------------------1")
o.clientsRwLocker.Lock() o.clientsRwLocker.Lock()
defer o.clientsRwLocker.Unlock() defer o.clientsRwLocker.Unlock()
var msg = WsSessionInfo{ var msg = WsSessionInfo{
Type: msgType, Type: msgType,
Content: message, Content: message,
} }
fmt.Println("ChatRoom.SendSessionMessage ------------------2")
msgBytes, _ := json.Marshal(msg) msgBytes, _ := json.Marshal(msg)
if o.Session[sessionId] == nil { if o.Session[sessionId] == nil {
err = fmt.Errorf("该会话不存在或已失效") err = fmt.Errorf("该会话不存在或已失效")

View File

@ -21,75 +21,65 @@ import (
) )
func AuthorizationVerify(sourceData []byte) (userInfo *accountFiee.ChatUserData, ok bool, err error) { func AuthorizationVerify(sourceData []byte) (userInfo *accountFiee.ChatUserData, ok bool, err error) {
fmt.Println("AuthorizationVerify ----------------1")
var msg AuthorizationInfo var msg AuthorizationInfo
err = json.Unmarshal(sourceData, &msg) err = json.Unmarshal(sourceData, &msg)
if err != nil { if err != nil {
return return
} }
fmt.Println("AuthorizationVerify ----------------2")
if msg.Type != AuthorizationType { if msg.Type != AuthorizationType {
return return
} }
fmt.Println("AuthorizationVerify ----------------3")
if msg.Content.Auth == "" { if msg.Content.Auth == "" {
return return
} }
fmt.Println("AuthorizationVerify ----------------4")
var check = true
var ctx = context.Background() var ctx = context.Background()
var accountInfo accountFiee.ChatUserData var accountInfo accountFiee.ChatUserData
//fiee token校验 switch msg.Content.Domain {
var fieeJwtInfo *jwt.Claims case config.AppConfig.System.Domain:
fieeJwtInfo, err = jwt.ParseToken(msg.Content.Auth, m.JWTSecret) //fiee token校验
if err != nil { var fieeJwtInfo *jwt.Claims
check = false fieeJwtInfo, err = jwt.ParseToken(msg.Content.Auth, m.JWTSecret)
fmt.Printf("fiee token parse err:%v\n", err) if err != nil {
} else { fmt.Printf("fiee token parse err:%v\n", err)
fmt.Printf("fieeJwtInfo :%#v\n", fieeJwtInfo) return
accountInfo.Origin = config.AppConfig.System.Domain }
//accountInfo.OriginId = int64(fieeJwtInfo.ID) accountInfo.Origin = msg.Content.Domain
accountInfo.OriginId = int64(fieeJwtInfo.ID)
accountInfo.Account = fieeJwtInfo.Account accountInfo.Account = fieeJwtInfo.Account
accountInfo.NickName = fieeJwtInfo.NickName accountInfo.NickName = fieeJwtInfo.NickName
infoReq := &accountFiee.UserByTelRequest{ infoReq := &accountFiee.UserByTelRequest{
Tel: fieeJwtInfo.Phone, Tel: fieeJwtInfo.Phone,
Domain: config.AppConfig.System.Domain, Domain: fieeJwtInfo.Domain,
} }
var accInfo *accountFiee.UserInfoResponse var accInfo *accountFiee.UserInfoResponse
accInfo, err = service.AccountFieeProvider.UserByTel(ctx, infoReq) accInfo, err = service.AccountFieeProvider.UserByTel(ctx, infoReq)
if err != nil { if err != nil {
check = false
fmt.Printf("err:%#v\n", err) fmt.Printf("err:%#v\n", err)
} else if accInfo != nil { return
fmt.Printf("fiee accInfo :%#v\n", accInfo) }
accountInfo.OriginId = int64(accInfo.Id) if accInfo != nil {
accountInfo.Account = accInfo.TelNum accountInfo.Account = accInfo.TelNum
accountInfo.Avatar = accInfo.GroupPhoto accountInfo.Avatar = accInfo.GroupPhoto
if accInfo.Name != "" { if accInfo.Name != "" {
accountInfo.NickName = accInfo.Name accountInfo.NickName = accInfo.Name
} }
} }
} case e.ErpDomain:
if !check { //erp token校验
msg.Content.Auth, err = secret.GetJwtFromStr(msg.Content.Auth) msg.Content.Auth, err = secret.GetJwtFromStr(msg.Content.Auth)
if err != nil { if err != nil {
check = false return
} else {
var fontreeJwtInfo *account.DecryptJwtResponse
fontreeJwtInfo, err = service.AccountProvider.DecryptJwt(ctx, &account.DecryptJwtRequest{Token: msg.Content.Auth, Domain: e.ErpDomain})
if err != nil || fontreeJwtInfo.IsOffline {
check = false
} else {
fmt.Printf("fontreeJwtInfo is %#v\n", fontreeJwtInfo)
accountInfo.Origin = e.ErpDomain
accountInfo.OriginId = int64(fontreeJwtInfo.ID)
accountInfo.Account = fontreeJwtInfo.Account
accountInfo.NickName = fontreeJwtInfo.NickName
}
} }
} var fontreeJwtInfo *account.DecryptJwtResponse
if !check { fontreeJwtInfo, err = service.AccountProvider.DecryptJwt(ctx, &account.DecryptJwtRequest{Token: msg.Content.Auth, Domain: msg.Content.Domain})
return if err != nil || fontreeJwtInfo.IsOffline {
return
}
fmt.Printf("fontreeJwtInfo is %#v\n", fontreeJwtInfo)
accountInfo.Origin = msg.Content.Domain
accountInfo.OriginId = int64(fontreeJwtInfo.ID)
accountInfo.Account = fontreeJwtInfo.Account
accountInfo.NickName = fontreeJwtInfo.NickName
} }
//查询是否已经注册 //查询是否已经注册

View File

@ -337,7 +337,7 @@ func UploadWithBuffer(fileBuffer *bytes.Buffer, cloudStoreSubPath string) (url s
return return
} }
cloudStoreSubPath = getEnvDir(cloudStoreSubPath) cloudStoreSubPath = getEnvDir(cloudStoreSubPath)
url, err = Client.PutObjectFromBytes(config.ConfigData.Oss.BucketName, cloudStoreSubPath, fileBuffer.Bytes()) _, err = Client.PutObjectFromBytes(config.ConfigData.Oss.BucketName, cloudStoreSubPath, fileBuffer.Bytes())
return return
} }
func getEnvDir(cloudStoreSubPath string) (ep string) { func getEnvDir(cloudStoreSubPath string) (ep string) {