i/activity/about_me.json?contributor_details=1&include_entities=true&include_my_retweet=true&send_error_codes=true
(c *fiber.Ctx)
| 147 | |
| 148 | // /i/activity/about_me.json?contributor_details=1&include_entities=true&include_my_retweet=true&send_error_codes=true |
| 149 | func GetMyActivity(c *fiber.Ctx) error { |
| 150 | // Thank you so much @Savefade for what this returns for follows. |
| 151 | // This function very optimized because before it would take 7 seconds lmao |
| 152 | // we thank our AI overloads. |
| 153 | my_did, pds, _, oauthToken, err := GetAuthFromReq(c) |
| 154 | if err != nil { |
| 155 | return MissingAuth(c, err) |
| 156 | } |
| 157 | |
| 158 | // Handle pagination |
| 159 | context := "" |
| 160 | maxID := c.Query("max_id") |
| 161 | if maxID != "" { |
| 162 | maxIDInt, err := strconv.ParseInt(maxID, 10, 64) |
| 163 | if err != nil { |
| 164 | return ReturnError(c, "An invalid max_id was specified", 195, fiber.StatusBadRequest) |
| 165 | } |
| 166 | maxIDInt-- |
| 167 | max_time := time.UnixMilli(maxIDInt) |
| 168 | context = max_time.Format(time.RFC3339) |
| 169 | } |
| 170 | |
| 171 | // Handle count |
| 172 | count := 20 |
| 173 | if countStr := c.Query("count"); countStr != "" { |
| 174 | if countInt, err := strconv.Atoi(countStr); err == nil { |
| 175 | count = countInt |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Get notifications |
| 180 | bskyNotifications, err := blueskyapi.GetNotifications(*pds, *oauthToken, count, context) |
| 181 | if err != nil { |
| 182 | return HandleBlueskyError(c, err.Error(), "app.bsky.notification.listNotifications", GetMyActivity) |
| 183 | } |
| 184 | |
| 185 | // Track unique users and posts |
| 186 | uniqueUsers := make(map[string]bool) |
| 187 | uniquePosts := make(map[string]bool) |
| 188 | |
| 189 | // First pass: collect unique users and posts |
| 190 | for _, notification := range bskyNotifications.Notifications { |
| 191 | uniqueUsers[notification.Author.DID] = true |
| 192 | if notification.ReasonSubject != "" { |
| 193 | uniquePosts[notification.ReasonSubject] = true |
| 194 | } |
| 195 | if notification.Reason == "mention" || notification.Reason == "reply" { |
| 196 | uniquePosts[notification.URI] = true |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // Convert maps to slices |
| 201 | usersToLookUp := make([]string, 0, len(uniqueUsers)) |
| 202 | postsToLookUp := make([]string, 0, len(uniquePosts)) |
| 203 | for user := range uniqueUsers { |
| 204 | usersToLookUp = append(usersToLookUp, user) |
| 205 | } |
| 206 | for post := range uniquePosts { |
nothing calls this directly
no test coverage detected