(pds string, token string, limit int, context string)
| 1941 | } |
| 1942 | |
| 1943 | func 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(¬ifications); err != nil { |
| 1970 | return nil, err |
| 1971 | } |
| 1972 | |
| 1973 | return ¬ifications, nil |
| 1974 | } |
| 1975 | |
| 1976 | func 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) |
nothing calls this directly
no test coverage detected