Эх сурвалжийг харах

Check errors of GetProfilePicThumb

When a request for GetProfilePicThumb fails, WhatsApp sends an JSON object
containing a status field: `{"status":404}`. In my tests, it did send the
codes 401 and 404 which might correspond to the HTTP status codes. At
least, we don't have data to update the avatar and should stop doing so.
Jörg Sommer 6 жил өмнө
parent
commit
95c8c01450

+ 6 - 0
portal.go

@@ -258,6 +258,12 @@ func (portal *Portal) UpdateAvatar(user *User, avatar *whatsappExt.ProfilePicInf
 		}
 		}
 	}
 	}
 
 
+	if avatar.Status != 0 {
+		// 401: ???
+		// 404: ???
+		return false
+	}
+
 	if portal.Avatar == avatar.Tag {
 	if portal.Avatar == avatar.Tag {
 		return false
 		return false
 	}
 	}

+ 2 - 0
whatsapp-ext/whatsapp.go

@@ -95,6 +95,8 @@ func (ext *ExtendedConn) GetGroupMetaData(jid string) (*GroupInfo, error) {
 type ProfilePicInfo struct {
 type ProfilePicInfo struct {
 	URL string `json:"eurl"`
 	URL string `json:"eurl"`
 	Tag string `json:"tag"`
 	Tag string `json:"tag"`
+
+	Status int16 `json:"status"`
 }
 }
 
 
 func (ppi *ProfilePicInfo) Download() (io.ReadCloser, error) {
 func (ppi *ProfilePicInfo) Download() (io.ReadCloser, error) {