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: failed get img url for NTQQ send #341 #343

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions client/pb/msg/msg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions client/pb/msg/msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -877,3 +877,41 @@ message MsgElemInfo_servtype37 {
optional bytes surpriseid = 8;
optional uint32 randomtype = 9;
}

message PbMultiMediaElement {
message Elem1 {
message Meta {
message Data {
optional int32 FileLen = 1;
optional bytes PicMd5 = 2;
}
optional Data data = 1;
optional string FilePath = 2;
}
optional Meta meta = 1;

message Data {
optional string ImgURL = 2;
optional string Domain = 3;
}
optional Data data = 2;
}
optional Elem1 elem1 = 1;

message Elem2 {
message Data {
message Friend {
optional string RKey = 30;
}
optional Friend friend = 11;
message Group {
optional string RKey = 30;
}
optional Group group = 12;
}
optional Data data = 1;
}
optional Elem2 elem2 = 2;
}


69 changes: 53 additions & 16 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ func ToSrcProtoElems(elems []IMessageElement) []*msg.Elem {

func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
var res []IMessageElement
var newImg = false
for _, elem := range elems {
if elem.SrcMsg != nil && len(elem.SrcMsg.OrigSeqs) != 0 {
r := &ReplyElement{
Expand Down Expand Up @@ -537,16 +538,18 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
bizType = ImageBizType(attr.ImageBizType.Unwrap())
}
}
res = append(res, &GroupImageElement{
FileId: int64(elem.CustomFace.FileId.Unwrap()),
ImageId: elem.CustomFace.FilePath.Unwrap(),
Size: elem.CustomFace.Size.Unwrap(),
Width: elem.CustomFace.Width.Unwrap(),
Height: elem.CustomFace.Height.Unwrap(),
Url: url,
ImageBizType: bizType,
Md5: elem.CustomFace.Md5,
})
if !newImg {
res = append(res, &GroupImageElement{
FileId: int64(elem.CustomFace.FileId.Unwrap()),
ImageId: elem.CustomFace.FilePath.Unwrap(),
Size: elem.CustomFace.Size.Unwrap(),
Width: elem.CustomFace.Width.Unwrap(),
Height: elem.CustomFace.Height.Unwrap(),
Url: url,
ImageBizType: bizType,
Md5: elem.CustomFace.Md5,
})
}
}
if elem.MarketFace != nil {
face := &MarketFaceElement{
Expand Down Expand Up @@ -582,6 +585,7 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
return []IMessageElement{face}
}

if elem.NotOnlineImage != nil {
img := elem.NotOnlineImage

Expand All @@ -603,13 +607,17 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
url += downloadPath + "/0?term=3"
}

res = append(res, &FriendImageElement{
ImageId: img.FilePath.Unwrap(),
Size: img.FileLen.Unwrap(),
Url: url,
Md5: img.PicMd5,
})
if !newImg {
res = append(res, &FriendImageElement{
ImageId: img.FilePath.Unwrap(),
Size: img.FileLen.Unwrap(),
Url: url,
Md5: img.PicMd5,
})
}

}

if elem.QQWalletMsg != nil && elem.QQWalletMsg.AioBody != nil {
// /com/tencent/mobileqq/data/MessageForQQWalletMsg.java#L366
msgType := elem.QQWalletMsg.AioBody.MsgType.Unwrap()
Expand Down Expand Up @@ -663,7 +671,36 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
Name: strings.TrimPrefix(string(animatedStickerMsg.Text), "/"),
}
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
}
}

}
}
return res
Expand Down
Loading