|
|
|
@ -2,7 +2,6 @@ package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
|
|
|
|
@ -16,7 +15,6 @@ import (
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/gin-gonic/gin/binding"
|
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
|
|
@ -150,38 +148,14 @@ func (m *Message) AddMessageReactionExtensions(c *gin.Context) {
|
|
|
|
|
func (m *Message) DeleteMessageReactionExtensions(c *gin.Context) {
|
|
|
|
|
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:
|
|
|
|
|
fmt.Println("1", sessionType)
|
|
|
|
|
if fl.StructFieldName() == "RecvID" {
|
|
|
|
|
fmt.Println("2", sessionType)
|
|
|
|
|
|
|
|
|
|
return fl.Field().String() != ""
|
|
|
|
|
}
|
|
|
|
|
case 2, 3:
|
|
|
|
|
fmt.Println("3", sessionType)
|
|
|
|
|
|
|
|
|
|
if fl.StructFieldName() == "GroupID" {
|
|
|
|
|
fmt.Println("4", sessionType)
|
|
|
|
|
|
|
|
|
|
return fl.Field().String() != ""
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
func (m *Message) SendMessage(c *gin.Context) {
|
|
|
|
|
params := apistruct.ManagementSendMsgReq{}
|
|
|
|
|
if err := c.BindJSON(¶ms); err != nil {
|
|
|
|
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
|
|
|
|
_ = v.RegisterValidation("required_if", RequiredIf)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data interface{}
|
|
|
|
|
switch params.ContentType {
|
|
|
|
|
case constant.Text:
|
|
|
|
|