MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / UploadGroupRecord

Method UploadGroupRecord

client/richmedia.go:243–297  ·  view source on GitHub ↗
(groupUin uint32, record *message.VoiceElement)

Source from the content-addressed store, hash-verified

241}
242
243func (c *QQClient) UploadGroupRecord(groupUin uint32, record *message.VoiceElement) (*message.VoiceElement, error) {
244 if record == nil || record.Stream == nil {
245 return nil, errors.New("element type is not voice record")
246 }
247 defer utils.CloseIO(record.Stream)
248 req, err := oidb.BuildGroupRecordUploadReq(groupUin, record)
249 if err != nil {
250 return nil, err
251 }
252 resp, err := c.sendOidbPacketAndWait(req)
253 if err != nil {
254 return nil, err
255 }
256 uploadResp, err := oidb.ParseGroupRecordUploadResp(resp)
257 if err != nil {
258 return nil, err
259 }
260 ukey := uploadResp.Upload.UKey.Unwrap()
261 c.debugln("group record upload ukey:", ukey)
262 if ukey != "" {
263 index := uploadResp.Upload.MsgInfo.MsgInfoBody[0].Index
264 sha1, err := hex.DecodeString(index.Info.FileSha1)
265 if err != nil {
266 return nil, err
267 }
268 extend := &highway.NTV2RichMediaHighwayExt{
269 FileUuid: index.FileUuid,
270 UKey: ukey,
271 Network: &highway.NTHighwayNetwork{
272 IPv4S: oidbIPv4ToNTHighwayIPv4(uploadResp.Upload.IPv4S),
273 },
274 MsgInfoBody: uploadResp.Upload.MsgInfo.MsgInfoBody,
275 BlockSize: uint32(highway2.BlockSize),
276 Hash: &highway.NTHighwayHash{
277 FileSha1: [][]byte{sha1},
278 },
279 }
280 extStream, err := proto.Marshal(extend)
281 if err != nil {
282 return nil, err
283 }
284 hash, err := hex.DecodeString(index.Info.FileHash)
285 if err != nil {
286 return nil, err
287 }
288 err = c.highwayUpload(1008, record.Stream, uint64(record.Size), hash, extStream)
289 if err != nil {
290 return nil, err
291 }
292 }
293 record.MsgInfo = uploadResp.Upload.MsgInfo
294 record.UUID = uploadResp.Upload.MsgInfo.MsgInfoBody[0].Index.FileUuid
295 record.Compat = uploadResp.Upload.CompatQMsg
296 return record, nil
297}
298
299func (c *QQClient) UploadPrivateVideo(targetUID string, video *message.ShortVideoElement) (*message.ShortVideoElement, error) {
300 if video == nil || video.Stream == nil {

Callers 2

UploadRecordMethod · 0.95

Calls 6

sendOidbPacketAndWaitMethod · 0.95
debuglnMethod · 0.95
highwayUploadMethod · 0.95
CloseIOFunction · 0.92
MarshalFunction · 0.92
oidbIPv4ToNTHighwayIPv4Function · 0.85

Tested by

no test coverage detected