Skip to content

Commit

Permalink
client: don't return typed nil in UploadImage
Browse files Browse the repository at this point in the history
  • Loading branch information
wdvxdr1123 committed Jun 18, 2022
1 parent 3f5174d commit 6e1792c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func (c *QQClient) UploadImage(target message.Source, img io.ReadSeeker, thread
case message.SourceGroup, message.SourceGuildChannel, message.SourceGuildDirect:
return c.uploadGroupOrGuildImage(target, img, thread...)
case message.SourcePrivate:
return c.uploadPrivateImage(target.PrimaryID, img, 0)
img, err := c.uploadPrivateImage(target.PrimaryID, img, 0)
// Note: we need this check, we should return untyped nil instead of (*FriendImageElement)(nil)
// TODO: change c.uploadPrivateImage signature after delete c.UploadPrivateImage
if err != nil {
return nil, err
}
return img, nil
default:
return nil, errors.New("unsupported target type")
}
Expand Down

0 comments on commit 6e1792c

Please sign in to comment.