Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic occurred when receive voice record in group message #349

Closed
wants to merge 10 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,32 +672,36 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
return []IMessageElement{sticker} // sticker 永远为单独消息
case 48:
img := &msg.PbMultiMediaElement{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, img)
domain := img.Elem1.Data.Domain.Unwrap()
imgURL := img.Elem1.Data.ImgURL.Unwrap()

if img.Elem2.Data.Friend != nil {
rKey := img.Elem2.Data.Friend.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &FriendImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url,
Md5: img.Elem1.Meta.Data.PicMd5,
})
newImg = true
}
if img.Elem2.Data.Group != nil {
rKey := img.Elem2.Data.Group.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &GroupImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url,
Md5: img.Elem1.Meta.Data.PicMd5,
})
newImg = true
bt := elem.CommonElem.BusinessType.Unwrap()
// 20 for group, 10 for friend, 22 or 12 for voice record
if bt == 20 || bt == 10 {
fumiama marked this conversation as resolved.
Show resolved Hide resolved
img := &msg.PbMultiMediaElement{}
_ = proto.Unmarshal(elem.CommonElem.PbElem, img)
domain := img.Elem1.Data.Domain.Unwrap()
imgURL := img.Elem1.Data.ImgURL.Unwrap()

if img.Elem2.Data.Friend != nil {
rKey := img.Elem2.Data.Friend.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &FriendImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url,
Md5: img.Elem1.Meta.Data.PicMd5,
})
newImg = true
}
if img.Elem2.Data.Group != nil {
rKey := img.Elem2.Data.Group.RKey.Unwrap()
url := fmt.Sprintf("https://%s%s%s&spec=0&rf=naio", domain, imgURL, rKey)
res = append(res, &GroupImageElement{
ImageId: img.Elem1.Meta.FilePath.Unwrap(),
Size: img.Elem1.Meta.Data.FileLen.Unwrap(),
Url: url,
Md5: img.Elem1.Meta.Data.PicMd5,
})
newImg = true
}
}
}

Expand Down