From 2cf0ad7d0105076f401d35235416c92ee506a449 Mon Sep 17 00:00:00 2001 From: divyam234 Date: Mon, 28 Aug 2023 12:00:04 +0530 Subject: [PATCH] update user profile check --- services/user.service.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/user.service.go b/services/user.service.go index 46f348a..e9d752d 100644 --- a/services/user.service.go +++ b/services/user.service.go @@ -3,6 +3,7 @@ package services import ( "bytes" "context" + "errors" "fmt" "net/http" "strconv" @@ -70,10 +71,10 @@ func (us *UserService) GetProfilePhoto(c *gin.Context) { return err } peer := self.AsInputPeer() - if self.Photo == nil { - return nil + photo, ok := self.Photo.AsNotEmpty() + if !ok { + return errors.New("profile not found") } - photo, _ := self.Photo.AsNotEmpty() location := &tg.InputPeerPhotoFileLocation{Big: false, Peer: peer, PhotoID: photo.PhotoID} buff, err := iterContent(c, client, location) if err != nil { @@ -88,7 +89,7 @@ func (us *UserService) GetProfilePhoto(c *gin.Context) { return nil }) if err != nil { - http.Error(c.Writer, err.Error(), http.StatusBadRequest) + c.AbortWithError(http.StatusNotFound, err) return } }