Skip to content

Commit

Permalink
fix: update logs add ex filed and remove set self userinfo with ex. (#…
Browse files Browse the repository at this point in the history
…496)

* fix: remove some code to avoid creating group errors..

Signed-off-by: Gordon <[email protected]>

* fix: find message add local Ex.

Signed-off-by: Gordon <[email protected]>

* fix: notification conversation update.

Signed-off-by: Gordon <[email protected]>

* fix: unread num is negative and optimization of sync conversation when app login or re conn.

Signed-off-by: Gordon <[email protected]>

* fix: update logs add ex filed and remove set self userinfo with ex.

Signed-off-by: Gordon <[email protected]>

---------

Signed-off-by: Gordon <[email protected]>
  • Loading branch information
FGadvancer authored Jan 15, 2024
1 parent 07aa773 commit 50da72d
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 60 deletions.
1 change: 1 addition & 0 deletions internal/conversation_msg/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ func (c *Conversation) MarkConversationMessageAsRead(ctx context.Context, conver
return c.markConversationMessageAsRead(ctx, conversationID)
}

// deprecated
func (c *Conversation) MarkMessagesAsReadByMsgID(ctx context.Context, conversationID string, clientMsgIDs []string) error {
return c.markMessagesAsReadByMsgID(ctx, conversationID, clientMsgIDs)
}
Expand Down
9 changes: 5 additions & 4 deletions internal/third/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"time"
)

func (c *Third) UploadLogs(ctx context.Context, progress Progress) error {
func (c *Third) UploadLogs(ctx context.Context, ex string, progress Progress) error {
logFilePath := c.LogFilePath
entrys, err := os.ReadDir(logFilePath)
entries, err := os.ReadDir(logFilePath)
if err != nil {
return err
}
files := make([]string, 0, len(entrys))
for _, entry := range entrys {
files := make([]string, 0, len(entries))
for _, entry := range entries {
if (!entry.IsDir()) && (!strings.HasSuffix(entry.Name(), ".zip")) && checkLogPath(entry.Name()) {
files = append(files, filepath.Join(logFilePath, entry.Name()))
}
Expand All @@ -48,6 +48,7 @@ func (c *Third) UploadLogs(ctx context.Context, progress Progress) error {
SystemType: c.systemType,
Version: c.version,
FileURLs: []*third.FileURL{{Filename: zippath, URL: resp.URL}},
Ex: ex,
}
_, err = util.CallApi[third.UploadLogsResp](ctx, constant.UploadLogsRouter, reqLog)
return err
Expand Down
7 changes: 2 additions & 5 deletions internal/user/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ func (u *User) GetSelfUserInfo(ctx context.Context) (*model_struct.LocalUser, er
return u.getSelfUserInfo(ctx)
}

// Deprecated: user SetSelfInfoEx instead
func (u *User) SetSelfInfo(ctx context.Context, userInfo *sdkws.UserInfo) error {
func (u *User) SetSelfInfo(ctx context.Context, userInfo *sdkws.UserInfoWithEx) error {
return u.updateSelfUserInfo(ctx, userInfo)
}
func (u *User) SetSelfInfoEx(ctx context.Context, userInfo *sdkws.UserInfoWithEx) error {
return u.updateSelfUserInfoEx(ctx, userInfo)
}

func (u *User) SetGlobalRecvMessageOpt(ctx context.Context, opt int) error {
if err := util.ApiPost(ctx, constant.SetGlobalRecvMessageOptRouter,
&pbUser.SetGlobalRecvMessageOptReq{UserID: u.loginUserID, GlobalRecvMsgOpt: int32(opt)}, nil); err != nil {
Expand Down
12 changes: 1 addition & 11 deletions internal/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,7 @@ func (u *User) getSelfUserInfo(ctx context.Context) (*model_struct.LocalUser, er
}

// updateSelfUserInfo updates the user's information.
func (u *User) updateSelfUserInfo(ctx context.Context, userInfo *sdkws.UserInfo) error {
userInfo.UserID = u.loginUserID
if err := util.ApiPost(ctx, constant.UpdateSelfUserInfoRouter, userPb.UpdateUserInfoReq{UserInfo: userInfo}, nil); err != nil {
return err
}
_ = u.SyncLoginUserInfo(ctx)
return nil
}

// updateSelfUserInfoEx updates the user's information with Ex field.
func (u *User) updateSelfUserInfoEx(ctx context.Context, userInfo *sdkws.UserInfoWithEx) error {
func (u *User) updateSelfUserInfo(ctx context.Context, userInfo *sdkws.UserInfoWithEx) error {
userInfo.UserID = u.loginUserID
if err := util.ApiPost(ctx, constant.UpdateSelfUserInfoExRouter, userPb.UpdateUserInfoExReq{UserInfo: userInfo}, nil); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions open_im_sdk/third.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ func SetAppBadge(callback open_im_sdk_callback.Base, operationID string, appUnre
call(callback, operationID, UserForSDK.Third().SetAppBadge, appUnreadCount)
}

func UploadLogs(callback open_im_sdk_callback.Base, operationID string, progress open_im_sdk_callback.UploadLogProgress) {
call(callback, operationID, UserForSDK.Third().UploadLogs, third.Progress(progress))
func UploadLogs(callback open_im_sdk_callback.Base, operationID string, ex string, progress open_im_sdk_callback.UploadLogProgress) {
call(callback, operationID, UserForSDK.Third().UploadLogs, ex, third.Progress(progress))
}
5 changes: 0 additions & 5 deletions open_im_sdk/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ func GetUsersInfoFromSrv(callback open_im_sdk_callback.Base, operationID string,
}

// SetSelfInfo sets the user's own information.
// Deprecated: user SetSelfInfoEx instead
func SetSelfInfo(callback open_im_sdk_callback.Base, operationID string, userInfo string) {
call(callback, operationID, UserForSDK.User().SetSelfInfo, userInfo)
}

// SetSelfInfoEx sets the user's own information with Ex field.
func SetSelfInfoEx(callback open_im_sdk_callback.Base, operationID string, userInfo string) {
call(callback, operationID, UserForSDK.User().SetSelfInfoEx, userInfo)
}
func SetGlobalRecvMessageOpt(callback open_im_sdk_callback.Base, operationID string, opt int) {
call(callback, operationID, UserForSDK.User().SetGlobalRecvMessageOpt, opt)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/constant/server_api_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package constant
const (
GetSelfUserInfoRouter = "/user/get_self_user_info"
GetUsersInfoRouter = "/user/get_users_info"
UpdateSelfUserInfoRouter = "/user/update_user_info"
UpdateSelfUserInfoExRouter = "/user/update_user_info_ex"
SetGlobalRecvMessageOptRouter = "/user/set_global_msg_recv_opt"
ProcessUserCommandAdd = "/process_user_command_add"
Expand Down
28 changes: 1 addition & 27 deletions testv2/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package testv2

import (
"github.com/OpenIMSDK/protocol/wrapperspb"
"testing"
"time"

Expand Down Expand Up @@ -66,7 +65,7 @@ func Test_GetUsersInfoWithCache(t *testing.T) {
func Test_SetSelfInfo(t *testing.T) {
newNickName := "test"
//newFaceURL := "http://test.com"
err := open_im_sdk.UserForSDK.User().SetSelfInfo(ctx, &sdkws.UserInfo{
err := open_im_sdk.UserForSDK.User().SetSelfInfo(ctx, &sdkws.UserInfoWithEx{
Nickname: newNickName,
//FaceURL: newFaceURL,
})
Expand All @@ -85,31 +84,6 @@ func Test_SetSelfInfo(t *testing.T) {
t.Log(userInfo)
time.Sleep(time.Second * 10)
}
func Test_SetSelfInfoEx(t *testing.T) {
newNickName := "test"
//newFaceURL := "http://test.com"
err := open_im_sdk.UserForSDK.User().SetSelfInfoEx(ctx, &sdkws.UserInfoWithEx{
Nickname: newNickName,
//FaceURL: newFaceURL,
Ex: &wrapperspb.StringValue{
Value: "ASD",
},
})
newFaceURL := "http://test.com"

if err != nil {
t.Error(err)
}
userInfo, err := open_im_sdk.UserForSDK.User().GetSelfUserInfo(ctx)
if err != nil {
t.Error(err)
}
if userInfo.UserID != UserID && userInfo.Nickname != newNickName && userInfo.FaceURL != newFaceURL {
t.Error("user id not match")
}
t.Log(userInfo)
time.Sleep(time.Second * 10)
}

func Test_UpdateMsgSenderInfo(t *testing.T) {
err := open_im_sdk.UserForSDK.User().UpdateMsgSenderInfo(ctx, "test", "http://test.com")
Expand Down
1 change: 0 additions & 1 deletion wasm/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func registerFunc() {
wrapperUser := wasm_wrapper.NewWrapperUser(globalFuc)
js.Global().Set("getSelfUserInfo", js.FuncOf(wrapperUser.GetSelfUserInfo))
js.Global().Set("setSelfInfo", js.FuncOf(wrapperUser.SetSelfInfo))
js.Global().Set("setSelfInfoEx", js.FuncOf(wrapperUser.SetSelfInfoEx))
js.Global().Set("getUsersInfo", js.FuncOf(wrapperUser.GetUsersInfo))
js.Global().Set("getUsersInfoWithCache", js.FuncOf(wrapperUser.GetUsersInfoWithCache))
js.Global().Set("subscribeUsersStatus", js.FuncOf(wrapperUser.SubscribeUsersStatus))
Expand Down
5 changes: 1 addition & 4 deletions wasm/wasm_wrapper/wasm_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ func (w *WrapperUser) SetSelfInfo(_ js.Value, args []js.Value) interface{} {
callback := event_listener.NewBaseCallback(utils.FirstLower(utils.GetSelfFuncName()), w.commonFunc)
return event_listener.NewCaller(open_im_sdk.SetSelfInfo, callback, &args).AsyncCallWithCallback()
}
func (w *WrapperUser) SetSelfInfoEx(_ js.Value, args []js.Value) interface{} {
callback := event_listener.NewBaseCallback(utils.FirstLower(utils.GetSelfFuncName()), w.commonFunc)
return event_listener.NewCaller(open_im_sdk.SetSelfInfoEx, callback, &args).AsyncCallWithCallback()
}

func (w *WrapperUser) GetUsersInfo(_ js.Value, args []js.Value) interface{} {
callback := event_listener.NewBaseCallback(utils.FirstLower(utils.GetSelfFuncName()), w.commonFunc)
return event_listener.NewCaller(open_im_sdk.GetUsersInfo, callback, &args).AsyncCallWithCallback()
Expand Down

0 comments on commit 50da72d

Please sign in to comment.