Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun

This commit is contained in:
wangchuxiao
2022-05-10 10:45:21 +08:00
36 changed files with 158 additions and 82 deletions
+9
View File
@@ -37,3 +37,12 @@ type UserTokenResp struct {
CommResp
UserToken UserTokenInfo `json:"data"`
}
type ParseTokenReq struct {
OperationID string `json:"operationID" binding:"required"`
}
type ParseTokenResp struct {
CommResp
ExpireTime int64 `json:"token" binding:"required"`
}
+2
View File
@@ -267,3 +267,5 @@ func GroupIsBanPrivateChat(status int32) bool {
const BigVersion = "v3"
const LogFileName = "OpenIM.log"
const StatisticsTimeInterval = 10
+10
View File
@@ -135,9 +135,19 @@ func GetUserIDFromToken(token string, operationID string) (bool, string, string)
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, "", err.Error()
}
log.Debug(operationID, "token claims.ExpiresAt.Second() ", claims.ExpiresAt.Unix())
return true, claims.UID, ""
}
func GetUserIDFromTokenExpireTime(token string, operationID string) (bool, string, string, int64) {
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, "", err.Error(), 0
}
return true, claims.UID, "", claims.ExpiresAt.Unix()
}
func ParseTokenGetUserID(token string, operationID string) (error, string) {
claims, err := ParseToken(token, operationID)
if err != nil {
+5 -5
View File
@@ -6,7 +6,7 @@ import (
)
type Statistics struct {
Count *uint64
AllCount *uint64
ModuleName string
PrintArgs string
SleepTime int
@@ -17,16 +17,16 @@ func (s *Statistics) output() {
defer t.Stop()
var sum uint64
for {
sum = *s.Count
sum = *s.AllCount
select {
case <-t.C:
}
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.AllCount-sum, "total:", *s.AllCount)
}
}
func NewStatistics(count *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{Count: count, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
go p.output()
return p
}