refactor: verify if part is uploaded before returning

This commit is contained in:
divyam234 2024-07-07 12:28:07 +05:30
parent 6839766e0a
commit 5f0f1831e5

View file

@ -249,6 +249,14 @@ func (us *UploadService) UploadFile(c *gin.Context) (*schemas.UploadPartOut, *ty
return err
}
//verify if the part is uploaded
msgs, _ := client.ChannelsGetMessages(ctx,
&tg.ChannelsGetMessagesRequest{Channel: channel, ID: []tg.InputMessageClass{&tg.InputMessageID{ID: message.ID}}})
if msgs != nil && len(msgs.(*tg.MessagesChannelMessages).Messages) == 0 {
return errors.New("upload failed")
}
out = mapper.ToUploadOut(partUpload)
return nil