Skip to content

Commit

Permalink
fix: set correct Wallposts count for WallGet method
Browse files Browse the repository at this point in the history
default value for "count" was 20, which was not specified anywhere
  • Loading branch information
alphatoasterous committed Mar 25, 2024
1 parent 0584666 commit f0b0f71
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api_utils/wall.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ func GetAllPostponedWallposts(vkUser *api.VK, domain string) ([]object.WallWallp
var allPosts [][]object.WallWallpost
var offset int
for {
response, err := vkUser.WallGet(api.Params{"domain": domain, "offset": offset, "filter": "postponed"})
const maxWallPostCount = 100
response, err := vkUser.WallGet(
api.Params{"domain": domain, "offset": offset, "filter": "postponed", "count": maxWallPostCount})
if err != nil {
log.Fatal(err)
return nil, err
}
allPosts = append(allPosts, response.Items)
if len(allPosts)*100 >= response.Count {
if len(allPosts)*maxWallPostCount >= response.Count {
break
}
offset += 100
offset += maxWallPostCount
}
return flattenWallpostArray(allPosts), nil
}
Expand Down

0 comments on commit f0b0f71

Please sign in to comment.