mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 19:50:07 +08:00
user update
This commit is contained in:
parent
357245691d
commit
b24960449d
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
@ -148,13 +149,31 @@ func (m *Message) AddMessageReactionExtensions(c *gin.Context) {
|
|||||||
func (m *Message) DeleteMessageReactionExtensions(c *gin.Context) {
|
func (m *Message) DeleteMessageReactionExtensions(c *gin.Context) {
|
||||||
a2r.Call(msg.MsgClient.DeleteMessageReactionExtensions, m.client, c)
|
a2r.Call(msg.MsgClient.DeleteMessageReactionExtensions, m.client, c)
|
||||||
}
|
}
|
||||||
|
func RequiredIf(fl validator.FieldLevel) bool {
|
||||||
|
sessionType := fl.Parent().FieldByName("SessionType").Int()
|
||||||
|
switch sessionType {
|
||||||
|
case 1, 4:
|
||||||
|
if fl.StructFieldName() == "RecvID" {
|
||||||
|
return fl.Field().String() != ""
|
||||||
|
}
|
||||||
|
case 2, 3:
|
||||||
|
if fl.StructFieldName() == "GroupID" {
|
||||||
|
return fl.Field().String() != ""
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
func (m *Message) SendMessage(c *gin.Context) {
|
func (m *Message) SendMessage(c *gin.Context) {
|
||||||
params := apistruct.ManagementSendMsgReq{}
|
params := apistruct.ManagementSendMsgReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||||
|
_ = v.RegisterValidation("required_if", RequiredIf)
|
||||||
|
}
|
||||||
var data interface{}
|
var data interface{}
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user