mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: solve the valiable shadows problem
This commit is contained in:
parent
10ad7bbe8c
commit
41de2303ce
@ -16,7 +16,6 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/protocol/msg"
|
"github.com/OpenIMSDK/protocol/msg"
|
||||||
@ -417,6 +416,7 @@ func (m *MessageApi) CallbackExample(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// Processing text messages
|
// Processing text messages
|
||||||
if req.ContentType == constant.Picture || req.ContentType == constant.Text {
|
if req.ContentType == constant.Picture || req.ContentType == constant.Text {
|
||||||
|
var err error
|
||||||
user, err := m.userRpcClient.GetUserInfo(c, robotics)
|
user, err := m.userRpcClient.GetUserInfo(c, robotics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "CallbackExample get Sender failed", err)
|
log.ZError(c, "CallbackExample get Sender failed", err)
|
||||||
@ -458,27 +458,29 @@ func (m *MessageApi) CallbackExample(c *gin.Context) {
|
|||||||
if len(picture.SnapshotPicture.Type) == 0 {
|
if len(picture.SnapshotPicture.Type) == 0 {
|
||||||
picture.SnapshotPicture.Type = picture.SourcePicture.Type
|
picture.SnapshotPicture.Type = picture.SourcePicture.Type
|
||||||
}
|
}
|
||||||
|
mapStructSnap := make(map[string]interface{})
|
||||||
mapStructSnap, err := convertStructToMap(picture.SnapshotPicture)
|
mapStructSnap, err = convertStructToMap(picture.SnapshotPicture)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "CallbackExample struct to map failed", err)
|
log.ZError(c, "CallbackExample struct to map failed", err)
|
||||||
apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mapStruct["snapshotPicture"] = mapStructSnap
|
mapStruct["snapshotPicture"] = mapStructSnap
|
||||||
|
|
||||||
mapStructBig, err := convertStructToMap(picture.BigPicture)
|
mapStructBig := make(map[string]interface{})
|
||||||
|
mapStructBig, err = convertStructToMap(picture.BigPicture)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "CallbackExample struct to map failed", err)
|
log.ZError(c, "CallbackExample struct to map failed", err)
|
||||||
apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mapStruct["bigPicture"] = mapStructBig
|
mapStruct["bigPicture"] = mapStructBig
|
||||||
|
|
||||||
mapStructSource, err := convertStructToMap(picture.SourcePicture)
|
mapStructSource := make(map[string]interface{})
|
||||||
|
mapStructSource, err = convertStructToMap(picture.SourcePicture)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "CallbackExample struct to map failed", err)
|
log.ZError(c, "CallbackExample struct to map failed", err)
|
||||||
apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mapStruct["sourcePicture"] = mapStructSource
|
mapStruct["sourcePicture"] = mapStructSource
|
||||||
@ -543,7 +545,7 @@ func convertStructToMap(input interface{}) (map[string]interface{}, error) {
|
|||||||
inputValue := reflect.ValueOf(input)
|
inputValue := reflect.ValueOf(input)
|
||||||
|
|
||||||
if inputType.Kind() != reflect.Struct {
|
if inputType.Kind() != reflect.Struct {
|
||||||
return nil, errors.New("input is not a struct")
|
return nil, errs.ErrArgs.Wrap("input is not a struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < inputType.NumField(); i++ {
|
for i := 0; i < inputType.NumField(); i++ {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user