Skip to content

Commit

Permalink
fix: fixed revoke burnMessage panic. (#672)
Browse files Browse the repository at this point in the history
* feat: implement panic recovery.

* update recover logic.

* update log print.

* feat: implment SDK log interface.

* update

* remove unused file.

* update Panic log print.

* fix: optimize delete msg local logic.

* update implement.

* optimize contents.

* fix: fix revoke burnMessage panic.

* update revoke logic.
  • Loading branch information
mo3et authored Aug 27, 2024
1 parent 9ebf5ef commit 6e3316e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
32 changes: 23 additions & 9 deletions internal/conversation_msg/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (c *Conversation) revokeMessage(ctx context.Context, tips *sdkws.RevokeMsgT
log.ZError(ctx, "GetMessageBySeq failed", err, "tips", &tips)
return errs.Wrap(err)
}

var revokerRole int32
var revokerNickname string
if tips.IsAdminRevoke || tips.SesstionType == constant.SingleChatType {
Expand All @@ -59,13 +60,15 @@ func (c *Conversation) revokeMessage(ctx context.Context, tips *sdkws.RevokeMsgT
} else {
log.ZDebug(ctx, "revoker user name", "userName", userName)
}

revokerNickname = userName
} else if tips.SesstionType == constant.SuperGroupChatType {
conversation, err := c.db.GetConversation(ctx, tips.ConversationID)
if err != nil {
log.ZError(ctx, "GetConversation failed", err, "conversationID", tips.ConversationID)
return errs.Wrap(err)
}

groupMember, err := c.db.GetGroupMemberInfoByGroupIDUserID(ctx, conversation.GroupID, tips.RevokerUserID)
if err != nil {
log.ZError(ctx, "GetGroupMemberInfoByGroupIDUserID failed", err, "tips", &tips)
Expand Down Expand Up @@ -134,26 +137,37 @@ func (c *Conversation) revokeMessage(ctx context.Context, tips *sdkws.RevokeMsgT
log.ZError(ctx, "SearchAllMessageByContentType failed", err, "tips", &tips)
return errs.Wrap(err)
}

for _, v := range msgList {
err = c.quoteMsgRevokeHandle(ctx, tips.ConversationID, v, m)
return errs.Wrap(err)
if err != nil {
log.ZError(ctx, "quote Msg Revoke Handle failed.", err, "chat Log content", v)
}
}
return nil
return errs.Wrap(err)
}

func (c *Conversation) quoteMsgRevokeHandle(ctx context.Context, conversationID string, v *model_struct.LocalChatLog, revokedMsg sdk_struct.MessageRevoked) error {
s := sdk_struct.MsgStruct{}
_ = utils.JsonStringToStruct(v.Content, &s.QuoteElem)
s := sdk_struct.QuoteElem{}
if v.Content == "" {
err := errs.New("Chat Log Content not found")
return errs.Wrap(err)
}

if s.QuoteElem.QuoteMessage == nil {
if err := utils.JsonStringToStruct(v.Content, &s); err != nil {
return errs.New("ChatLog content transfer failed.")
}

if s.QuoteMessage == nil {
return errs.New("QuoteMessage is nil").Wrap()
}
if s.QuoteElem.QuoteMessage.ClientMsgID != revokedMsg.ClientMsgID {
if s.QuoteMessage.ClientMsgID != revokedMsg.ClientMsgID {
return errs.New("quoteMessage ClientMsgID is not revokedMsg ClientMsgID").Wrap()
}
s.QuoteElem.QuoteMessage.Content = utils.StructToJsonString(revokedMsg)
s.QuoteElem.QuoteMessage.ContentType = constant.RevokeNotification
v.Content = utils.StructToJsonString(s.QuoteElem)

s.QuoteMessage.Content = utils.StructToJsonString(revokedMsg)
s.QuoteMessage.ContentType = constant.RevokeNotification
v.Content = utils.StructToJsonString(s)
if err := c.db.UpdateMessageBySeq(ctx, conversationID, v); err != nil {
log.ZError(ctx, "UpdateMessage failed", err, "v", v)
return errs.Wrap(err)
Expand Down
1 change: 1 addition & 0 deletions internal/interaction/long_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (c *LongConnMgr) writePump(ctx context.Context) {
log.ZWarn(ctx, "writePump panic", nil, "panic info", err)
}
}()

log.ZDebug(ctx, "writePump start", "goroutine ID:", getGoroutineID())

defer func() {
Expand Down
3 changes: 2 additions & 1 deletion wasm/event_listener/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func (r *ReflectCall) asyncCallWithOutCallback() {
if r.callback == nil {
r.callback = NewBaseCallback(utils.FirstLower(utils.GetSelfFuncName()), nil)
}
log.ZError(ctx, "test", nil, "asyncCallWithOutCallback", len(r.arguments))
log.ZWarn(ctx, "asyncCall", nil, "asyncCallWithOutCallback", len(r.arguments))

r.callback.SetOperationID(r.arguments[0].String())
//strings.SplitAfter()
for i := 0; i < len(r.arguments); i++ {
Expand Down

0 comments on commit 6e3316e

Please sign in to comment.