2023-02-09 16:11:18 +08:00
package callbackstruct
2022-02-28 17:57:03 +08:00
2023-01-05 18:32:30 +08:00
import (
"fmt"
2023-03-16 10:46:06 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
2023-01-05 18:32:30 +08:00
)
2022-02-28 17:57:03 +08:00
type CommonCallbackReq struct {
2022-06-30 18:50:10 +08:00
SendID string ` json:"sendID" `
CallbackCommand string ` json:"callbackCommand" `
ServerMsgID string ` json:"serverMsgID" `
ClientMsgID string ` json:"clientMsgID" `
OperationID string ` json:"operationID" `
SenderPlatformID int32 ` json:"senderPlatformID" `
SenderNickname string ` json:"senderNickname" `
SessionType int32 ` json:"sessionType" `
MsgFrom int32 ` json:"msgFrom" `
ContentType int32 ` json:"contentType" `
Status int32 ` json:"status" `
CreateTime int64 ` json:"createTime" `
Content string ` json:"content" `
2022-08-08 17:42:06 +08:00
Seq uint32 ` json:"seq" `
2022-06-30 18:50:10 +08:00
AtUserIDList [ ] string ` json:"atUserList" `
SenderFaceURL string ` json:"faceURL" `
2022-08-24 14:22:47 +08:00
Ex string ` json:"ex" `
2022-02-28 17:57:03 +08:00
}
2023-02-14 15:02:45 +08:00
func ( c * CommonCallbackReq ) GetCallbackCommand ( ) string {
return c . CallbackCommand
}
type CallbackReq interface {
GetCallbackCommand ( ) string
}
2023-01-05 18:32:30 +08:00
type CallbackResp interface {
2023-01-05 20:04:11 +08:00
Parse ( ) ( err error )
2023-01-05 18:32:30 +08:00
}
2022-02-28 17:57:03 +08:00
type CommonCallbackResp struct {
2023-02-14 15:02:45 +08:00
ActionCode int ` json:"actionCode" `
ErrCode int32 ` json:"errCode" `
ErrMsg string ` json:"errMsg" `
2022-02-28 17:57:03 +08:00
}
2022-05-26 18:02:00 +08:00
2023-02-14 19:28:57 +08:00
func ( c CommonCallbackResp ) Parse ( ) error {
2023-03-07 16:57:49 +08:00
if c . ActionCode != errs . NoError || c . ErrCode != errs . NoError {
2023-03-07 12:19:30 +08:00
return errs . NewCodeError ( int ( c . ErrCode ) , "Callback" ) . Wrap ( fmt . Sprintf ( "callback response error actionCode is %d, errCode is %d, errMsg is %s" , c . ActionCode , c . ErrCode , c . ErrMsg ) )
2023-01-05 18:32:30 +08:00
}
2023-02-14 15:02:45 +08:00
return nil
2023-01-05 18:32:30 +08:00
}
2022-07-29 14:36:07 +08:00
type UserStatusBaseCallback struct {
2022-05-26 18:02:00 +08:00
CallbackCommand string ` json:"callbackCommand" `
OperationID string ` json:"operationID" `
2023-02-15 15:50:52 +08:00
PlatformID int ` json:"platformID" `
2022-05-26 18:02:00 +08:00
Platform string ` json:"platform" `
}
2022-07-29 14:36:07 +08:00
2023-02-15 15:50:52 +08:00
func ( c UserStatusBaseCallback ) GetCallbackCommand ( ) string {
return c . CallbackCommand
}
2022-07-29 14:36:07 +08:00
type UserStatusCallbackReq struct {
UserStatusBaseCallback
UserID string ` json:"userID" `
}
type UserStatusBatchCallbackReq struct {
UserStatusBaseCallback
UserIDList [ ] string ` json:"userIDList" `
}