1515package chat
1616
1717import (
18- "github.com/openimsdk/chat/internal/api/util"
1918 "io"
2019 "time"
2120
21+ "github.com/openimsdk/chat/internal/api/util"
22+
2223 "github.com/gin-gonic/gin"
2324 "github.com/openimsdk/chat/pkg/common/apistruct"
24- chatconstant "github.com/openimsdk/chat/pkg/common/constant"
25+ "github.com/openimsdk/chat/pkg/common/constant"
2526 "github.com/openimsdk/chat/pkg/common/imapi"
2627 "github.com/openimsdk/chat/pkg/common/mctx"
2728 "github.com/openimsdk/chat/pkg/protocol/admin"
28- "github.com/openimsdk/chat/pkg/protocol/chat"
29- "github.com/openimsdk/protocol/constant"
29+ chatpb "github.com/openimsdk/chat/pkg/protocol/chat"
30+ constantpb "github.com/openimsdk/protocol/constant"
3031 "github.com/openimsdk/protocol/sdkws"
3132 "github.com/openimsdk/tools/a2r"
3233 "github.com/openimsdk/tools/apiresp"
3334 "github.com/openimsdk/tools/errs"
3435)
3536
36- func New (chatClient chat .ChatClient , adminClient admin.AdminClient , imApiCaller imapi.CallerInterface , api * util.Api ) * Api {
37+ func New (chatClient chatpb .ChatClient , adminClient admin.AdminClient , imApiCaller imapi.CallerInterface , api * util.Api ) * Api {
3738 return & Api {
3839 Api : api ,
3940 chatClient : chatClient ,
@@ -44,15 +45,15 @@ func New(chatClient chat.ChatClient, adminClient admin.AdminClient, imApiCaller
4445
4546type Api struct {
4647 * util.Api
47- chatClient chat .ChatClient
48+ chatClient chatpb .ChatClient
4849 adminClient admin.AdminClient
4950 imApiCaller imapi.CallerInterface
5051}
5152
5253// ################## ACCOUNT ##################
5354
5455func (o * Api ) SendVerifyCode (c * gin.Context ) {
55- req , err := a2r.ParseRequest [chat .SendVerifyCodeReq ](c )
56+ req , err := a2r.ParseRequest [chatpb .SendVerifyCodeReq ](c )
5657 if err != nil {
5758 apiresp .GinError (c , err )
5859 return
@@ -72,11 +73,11 @@ func (o *Api) SendVerifyCode(c *gin.Context) {
7273}
7374
7475func (o * Api ) VerifyCode (c * gin.Context ) {
75- a2r .Call (chat .ChatClient .VerifyCode , o .chatClient , c )
76+ a2r .Call (chatpb .ChatClient .VerifyCode , o .chatClient , c )
7677}
7778
7879func (o * Api ) RegisterUser (c * gin.Context ) {
79- req , err := a2r.ParseRequest [chat .RegisterUserReq ](c )
80+ req , err := a2r.ParseRequest [chatpb .RegisterUserReq ](c )
8081 if err != nil {
8182 apiresp .GinError (c , err )
8283 return
@@ -130,7 +131,7 @@ func (o *Api) RegisterUser(c *gin.Context) {
130131}
131132
132133func (o * Api ) Login (c * gin.Context ) {
133- req , err := a2r.ParseRequest [chat .LoginReq ](c )
134+ req , err := a2r.ParseRequest [chatpb .LoginReq ](c )
134135 if err != nil {
135136 apiresp .GinError (c , err )
136137 return
@@ -159,17 +160,17 @@ func (o *Api) Login(c *gin.Context) {
159160}
160161
161162func (o * Api ) ResetPassword (c * gin.Context ) {
162- a2r .Call (chat .ChatClient .ResetPassword , o .chatClient , c )
163+ a2r .Call (chatpb .ChatClient .ResetPassword , o .chatClient , c )
163164}
164165
165166func (o * Api ) ChangePassword (c * gin.Context ) {
166- a2r .Call (chat .ChatClient .ChangePassword , o .chatClient , c )
167+ a2r .Call (chatpb .ChatClient .ChangePassword , o .chatClient , c )
167168}
168169
169170// ################## USER ##################
170171
171172func (o * Api ) UpdateUserInfo (c * gin.Context ) {
172- req , err := a2r.ParseRequest [chat .UpdateUserInfoReq ](c )
173+ req , err := a2r.ParseRequest [chatpb .UpdateUserInfoReq ](c )
173174 if err != nil {
174175 apiresp .GinError (c , err )
175176 return
@@ -185,10 +186,10 @@ func (o *Api) UpdateUserInfo(c *gin.Context) {
185186 return
186187 }
187188 var imToken string
188- if opUserType == chatconstant .NormalUser {
189+ if opUserType == constant .NormalUser {
189190 imToken , err = o .imApiCaller .ImAdminTokenWithDefaultAdmin (c )
190- } else if opUserType == chatconstant .AdminUser {
191- imToken , err = o .imApiCaller .UserToken (c , o .GetDefaultIMAdminUserID (), constant .AdminPlatformID )
191+ } else if opUserType == constant .AdminUser {
192+ imToken , err = o .imApiCaller .UserToken (c , o .GetDefaultIMAdminUserID (), constantpb .AdminPlatformID )
192193 } else {
193194 apiresp .GinError (c , errs .ErrArgs .WrapMsg ("opUserType unknown" ))
194195 return
@@ -220,23 +221,23 @@ func (o *Api) UpdateUserInfo(c *gin.Context) {
220221}
221222
222223func (o * Api ) FindUserPublicInfo (c * gin.Context ) {
223- a2r .Call (chat .ChatClient .FindUserPublicInfo , o .chatClient , c )
224+ a2r .Call (chatpb .ChatClient .FindUserPublicInfo , o .chatClient , c )
224225}
225226
226227func (o * Api ) FindUserFullInfo (c * gin.Context ) {
227- a2r .Call (chat .ChatClient .FindUserFullInfo , o .chatClient , c )
228+ a2r .Call (chatpb .ChatClient .FindUserFullInfo , o .chatClient , c )
228229}
229230
230231func (o * Api ) SearchUserFullInfo (c * gin.Context ) {
231- a2r .Call (chat .ChatClient .SearchUserFullInfo , o .chatClient , c )
232+ a2r .Call (chatpb .ChatClient .SearchUserFullInfo , o .chatClient , c )
232233}
233234
234235func (o * Api ) SearchUserPublicInfo (c * gin.Context ) {
235- a2r .Call (chat .ChatClient .SearchUserPublicInfo , o .chatClient , c )
236+ a2r .Call (chatpb .ChatClient .SearchUserPublicInfo , o .chatClient , c )
236237}
237238
238239func (o * Api ) GetTokenForVideoMeeting (c * gin.Context ) {
239- a2r .Call (chat .ChatClient .GetTokenForVideoMeeting , o .chatClient , c )
240+ a2r .Call (chatpb .ChatClient .GetTokenForVideoMeeting , o .chatClient , c )
240241}
241242
242243// ################## APPLET ##################
@@ -259,8 +260,8 @@ func (o *Api) OpenIMCallback(c *gin.Context) {
259260 apiresp .GinError (c , err )
260261 return
261262 }
262- req := & chat .OpenIMCallbackReq {
263- Command : c .Query (constant .CallbackCommand ),
263+ req := & chatpb .OpenIMCallbackReq {
264+ Command : c .Query (constantpb .CallbackCommand ),
264265 Body : string (body ),
265266 }
266267 if _ , err := o .chatClient .OpenIMCallback (c , req ); err != nil {
@@ -273,7 +274,7 @@ func (o *Api) OpenIMCallback(c *gin.Context) {
273274func (o * Api ) SearchFriend (c * gin.Context ) {
274275 req , err := a2r.ParseRequest [struct {
275276 UserID string `json:"userID"`
276- chat .SearchUserInfoReq
277+ chatpb .SearchUserInfoReq
277278 }](c )
278279 if err != nil {
279280 apiresp .GinError (c , err )
@@ -293,7 +294,7 @@ func (o *Api) SearchFriend(c *gin.Context) {
293294 return
294295 }
295296 if len (userIDs ) == 0 {
296- apiresp .GinSuccess (c , & chat .SearchUserInfoResp {})
297+ apiresp .GinSuccess (c , & chatpb .SearchUserInfoResp {})
297298 return
298299 }
299300 req .SearchUserInfoReq .UserIDs = userIDs
0 commit comments