MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / GetNotifications

Function GetNotifications

bluesky/blueskyapi.go:1943–1974  ·  view source on GitHub ↗
(pds string, token string, limit int, context string)

Source from the content-addressed store, hash-verified

1941}
1942
1943func GetNotifications(pds string, token string, limit int, context string) (*Notifications, error) {
1944 url := pds + "/xrpc/app.bsky.notification.listNotifications?limit=" + fmt.Sprintf("%d", limit)
1945 if context != "" {
1946 url = pds + "/xrpc/app.bsky.notification.listNotifications?cursor=" + context + "&limit=" + fmt.Sprintf("%d", limit)
1947 }
1948
1949 resp, err := SendRequest(&token, http.MethodGet, url, nil)
1950 if err != nil {
1951 return nil, err
1952 }
1953 defer resp.Body.Close()
1954
1955 // // Print the response body for debugging
1956 // bodyBytes, _ := io.ReadAll(resp.Body)
1957 // bodyString := string(bodyBytes)
1958 // fmt.Println("Response Body:", bodyString)
1959
1960 if resp.StatusCode != http.StatusOK {
1961 bodyBytes, _ := io.ReadAll(resp.Body)
1962 bodyString := string(bodyBytes)
1963 fmt.Println("Response Status:", resp.StatusCode)
1964 fmt.Println("Response Body:", bodyString)
1965 return nil, errors.New(bodyString) // return response
1966 }
1967
1968 notifications := Notifications{}
1969 if err := json.NewDecoder(resp.Body).Decode(&notifications); err != nil {
1970 return nil, err
1971 }
1972
1973 return &notifications, nil
1974}
1975
1976func GetMentions(pds string, token string, limit int, context string) (*Notifications, error) {
1977 url := pds + "/xrpc/app.bsky.notification.listNotifications?reasons=mention&reasons=reply&reasons=quote&limit=" + fmt.Sprintf("%d", limit)

Callers

nothing calls this directly

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected