From bb3f658a78806b152709675e1fe217a8e9ce4606 Mon Sep 17 00:00:00 2001 From: Davincible Date: Sat, 21 Aug 2021 12:27:35 +0200 Subject: [PATCH] Add endpoint Timeline.NewFeedPostsExist --- const.go | 7 ++++--- timeline.go | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/const.go b/const.go index 26adffd..fe4f0cc 100644 --- a/const.go +++ b/const.go @@ -175,9 +175,10 @@ const ( urlSearchRegisterClick = "fbsearch/register_recent_search_click/" // Feeds - urlFeedLocationID = "feed/location/%d/" - urlFeedLocations = "locations/%d/sections/" - urlFeedTag = "feed/tag/%s/" + urlFeedLocationID = "feed/location/%d/" + urlFeedLocations = "locations/%d/sections/" + urlFeedTag = "feed/tag/%s/" + urlFeedNewPostsExist = "feed/new_feed_posts_exist/" // Media urlMediaInfo = "media/%s/info/" diff --git a/timeline.go b/timeline.go index 9be09b7..0ee0ab9 100644 --- a/timeline.go +++ b/timeline.go @@ -281,6 +281,26 @@ func (tl *Timeline) Refresh() error { return nil } +// NewFeedPostsExist will return true if new feed posts are available. +func (tl *Timeline) NewFeedPostsExist() (bool, error) { + insta := tl.insta + + body, err := insta.sendSimpleRequest(urlFeedNewPostsExist) + if err != nil { + return false, err + } + + var resp struct { + NewPosts bool `json:"new_feed_posts_exist"` + Status string `json:"status"` + } + err = json.Unmarshal(body, &resp) + if err != nil { + return false, err + } + return resp.NewPosts, nil +} + // Stories is a helper function to get the stories func (tl *Timeline) Stories() []Reel { return tl.Tray.Stories