@@ -16,6 +16,7 @@ package conversation_msg
16
16
17
17
import (
18
18
"context"
19
+ "errors"
19
20
20
21
"github.com/openimsdk/openim-sdk-core/v3/pkg/common"
21
22
"github.com/openimsdk/openim-sdk-core/v3/pkg/constant"
@@ -25,27 +26,34 @@ import (
25
26
"github.com/openimsdk/openim-sdk-core/v3/sdk_struct"
26
27
27
28
"github.com/openimsdk/protocol/sdkws"
29
+ "github.com/openimsdk/tools/errs"
28
30
"github.com/openimsdk/tools/log"
29
31
)
30
32
31
33
// Delete the local and server
32
- // Delete the local, do not change the server data
33
- // To delete the server, you need to change the local message status to delete
34
34
func (c * Conversation ) clearConversationFromLocalAndServer (ctx context.Context , conversationID string , f func (ctx context.Context , conversationID string ) error ) error {
35
35
_ , err := c .db .GetConversation (ctx , conversationID )
36
36
if err != nil {
37
37
return err
38
38
}
39
+
39
40
// Use conversationID to remove conversations and messages from the server first
40
41
err = c .clearConversationMsgFromServer (ctx , conversationID )
41
42
if err != nil {
42
- return err
43
+ if errors .Is (errs .Unwrap (err ), errs .ErrRecordNotFound ) {
44
+ log .ZWarn (ctx , "clearConversationMsgFromServer err" , err , "conversationID" , conversationID )
45
+ } else {
46
+ return err
47
+ }
43
48
}
49
+
44
50
if err := c .clearConversationAndDeleteAllMsg (ctx , conversationID , false , f ); err != nil {
45
51
return err
46
52
}
53
+
47
54
c .doUpdateConversation (common.Cmd2Value {Value : common.UpdateConNode {Action : constant .ConChange , Args : []string {conversationID }}})
48
55
c .doUpdateConversation (common.Cmd2Value {Value : common.UpdateConNode {Action : constant .TotalUnreadMessageChanged }})
56
+
49
57
return nil
50
58
}
51
59
0 commit comments