You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

callback.go 5.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // Copyright © 2023 OpenIM open source community. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package response
  15. import (
  16. "net/http"
  17. "github.com/gin-gonic/gin"
  18. "github.com/OpenIMSDK/OpenKF/server/internal/common"
  19. )
  20. // CommonCallbackResp Common callback response.
  21. type CommonCallbackResp struct {
  22. ActionCode int `json:"actionCode"`
  23. ErrCode int32 `json:"errCode"`
  24. ErrMsg string `json:"errMsg"`
  25. ErrDlt string `json:"errDlt"`
  26. }
  27. // NewCommonCallbackResp Create a new CommonCallbackResp.
  28. func NewCommonCallbackResp(actionCode int, errCode int32, errMsg string, errDlt string, c *gin.Context) {
  29. c.JSON(http.StatusOK, &CommonCallbackResp{
  30. ActionCode: actionCode,
  31. ErrCode: errCode,
  32. ErrMsg: errMsg,
  33. ErrDlt: errDlt,
  34. })
  35. }
  36. // CallbackBeforeSendSingleMsgResp Response body for BeforeSendSingleMsgCommand.
  37. type CallbackBeforeSendSingleMsgResp struct {
  38. CommonCallbackResp
  39. }
  40. // CallbackBeforeSendSingleMsgRespSuccess CallbackBeforeSendSingleMsgResp success response.
  41. func CallbackBeforeSendSingleMsgRespSuccess(c *gin.Context) {
  42. NewCommonCallbackResp(
  43. common.OPENIM_SERVER_ALLOW_ACTION,
  44. common.OPENIM_SERVER_ALLOW_ACTION,
  45. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  46. "", // todo
  47. c,
  48. )
  49. }
  50. // CallbackBeforeSendSingleMsgRespFail CallbackBeforeSendSingleMsgResp fail response.
  51. func CallbackBeforeSendSingleMsgRespFail(c *gin.Context) {
  52. NewCommonCallbackResp(
  53. common.OPENIM_SERVER_DENY_ACTION,
  54. common.OPENIM_SERVER_ALLOW_ACTION,
  55. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  56. "", // todo
  57. c,
  58. )
  59. }
  60. // CallbackAfterSendSingleMsgResp Response body for AfterSendSingleMsgCommand.
  61. type CallbackAfterSendSingleMsgResp struct {
  62. CommonCallbackResp
  63. }
  64. // CallbackAfterSendSingleMsgRespSuccess CallbackAfterSendSingleMsgResp success response.
  65. func CallbackAfterSendSingleMsgRespSuccess(c *gin.Context) {
  66. NewCommonCallbackResp(
  67. common.OPENIM_SERVER_ALLOW_ACTION,
  68. common.OPENIM_SERVER_ALLOW_ACTION,
  69. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  70. "", // todo
  71. c,
  72. )
  73. }
  74. // CallbackAfterSendSingleMsgRespFail CallbackAfterSendSingleMsgResp fail response.
  75. func CallbackAfterSendSingleMsgRespFail(c *gin.Context) {
  76. NewCommonCallbackResp(
  77. common.OPENIM_SERVER_DENY_ACTION,
  78. common.OPENIM_SERVER_ALLOW_ACTION,
  79. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  80. "", // todo
  81. c,
  82. )
  83. }
  84. // CallbackMsgModifyCommandResp Response body for MsgModifyCommand.
  85. type CallbackMsgModifyCommandResp struct {
  86. // todo: need to modify
  87. CommonCallbackResp
  88. Content *string `json:"content"`
  89. RecvID *string `json:"recvID"`
  90. GroupID *string `json:"groupID"`
  91. ClientMsgID *string `json:"clientMsgID"`
  92. ServerMsgID *string `json:"serverMsgID"`
  93. SenderPlatformID *int32 `json:"senderPlatformID"`
  94. SenderNickname *string `json:"senderNickname"`
  95. SenderFaceURL *string `json:"senderFaceURL"`
  96. SessionType *int32 `json:"sessionType"`
  97. MsgFrom *int32 `json:"msgFrom"`
  98. ContentType *int32 `json:"contentType"`
  99. Status *int32 `json:"status"`
  100. Options *map[string]bool `json:"options"`
  101. OfflinePushInfo interface{} `json:"offlinePushInfo"`
  102. // OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"`
  103. AtUserIDList *[]string `json:"atUserIDList"`
  104. MsgDataList *[]byte `json:"msgDataList"`
  105. AttachedInfo *string `json:"attachedInfo"`
  106. Ex *string `json:"ex"`
  107. }
  108. // CallbackUserOnlineResp Response body for UserOnlineCommand.
  109. type CallbackUserOnlineResp struct {
  110. CommonCallbackResp
  111. }
  112. // CallbackUserOnlineRespSuccess CallbackUserOnlineResp success response.
  113. func CallbackUserOnlineRespSuccess(c *gin.Context) {
  114. NewCommonCallbackResp(
  115. common.OPENIM_SERVER_ALLOW_ACTION,
  116. common.OPENIM_SERVER_ALLOW_ACTION,
  117. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  118. "", // todo
  119. c,
  120. )
  121. }
  122. // CallbackUserOnlineRespFail CallbackUserOnlineResp fail response.
  123. func CallbackUserOnlineRespFail(c *gin.Context) {
  124. NewCommonCallbackResp(
  125. common.OPENIM_SERVER_DENY_ACTION,
  126. common.OPENIM_SERVER_ALLOW_ACTION,
  127. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  128. "", // todo
  129. c,
  130. )
  131. }
  132. // CallbackUserOfflineResp Response body for UserOfflineCommand.
  133. type CallbackUserOfflineResp struct {
  134. CommonCallbackResp
  135. }
  136. // CallbackUserOfflineRespSuccess CallbackUserOfflineResp success response.
  137. func CallbackUserOfflineRespSuccess(c *gin.Context) {
  138. NewCommonCallbackResp(
  139. common.OPENIM_SERVER_ALLOW_ACTION,
  140. common.OPENIM_SERVER_ALLOW_ACTION,
  141. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  142. "", // todo
  143. c,
  144. )
  145. }
  146. // CallbackUserOfflineRespFail CallbackUserOfflineResp fail response.
  147. func CallbackUserOfflineRespFail(c *gin.Context) {
  148. NewCommonCallbackResp(
  149. common.OPENIM_SERVER_DENY_ACTION,
  150. common.OPENIM_SERVER_ALLOW_ACTION,
  151. common.GetMsg(common.OPENIM_SERVER_ALLOW_ACTION),
  152. "", // todo
  153. c,
  154. )
  155. }