fix: in standalone mode, the user online status is wrong

This commit is contained in:
withchao
2025-05-16 17:26:52 +08:00
parent 1144076168
commit cd2573534d
10 changed files with 127 additions and 109 deletions
+39
View File
@@ -0,0 +1,39 @@
package startrpc
import (
"reflect"
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
)
func getConfig[T any](value reflect.Value) *T {
for value.Kind() == reflect.Pointer {
value = value.Elem()
}
if value.Kind() == reflect.Struct {
num := value.NumField()
for i := 0; i < num; i++ {
field := value.Field(i)
for field.Kind() == reflect.Pointer {
field = field.Elem()
}
if field.Kind() == reflect.Struct {
if elem, ok := field.Interface().(T); ok {
return &elem
}
if elem := getConfig[T](field); elem != nil {
return elem
}
}
}
}
return nil
}
func getConfigRpcMaxRequestBody(value reflect.Value) *conf.MaxRequestBody {
return getConfig[conf.MaxRequestBody](value)
}
func getConfigShare(value reflect.Value) *conf.Share {
return getConfig[conf.Share](value)
}