Mentions timeline, using notifications to make my life hell
(c *fiber.Ctx)
| 864 | |
| 865 | // Mentions timeline, using notifications to make my life hell |
| 866 | func mentions_timeline(c *fiber.Ctx) error { |
| 867 | _, pds, _, oauthToken, err := GetAuthFromReq(c) |
| 868 | if err != nil { |
| 869 | return MissingAuth(c, err) |
| 870 | } |
| 871 | |
| 872 | // Handle pagination |
| 873 | context := "" |
| 874 | max_id := c.Query("max_id") |
| 875 | // Handle getting things in the past |
| 876 | if max_id != "" { |
| 877 | // Get the timeline context from the DB |
| 878 | maxIDInt, err := strconv.ParseInt(max_id, 10, 64) |
| 879 | fmt.Println("Max ID:", maxIDInt) |
| 880 | if err != nil { |
| 881 | return ReturnError(c, "Invalid max_id format", 195, fiber.StatusForbidden) |
| 882 | } |
| 883 | _, date, _, err := bridge.TwitterMsgIdToBluesky(&maxIDInt) |
| 884 | if err != nil { |
| 885 | return ReturnError(c, "max_id was not found", 144, fiber.StatusForbidden) |
| 886 | } |
| 887 | context = date.Format(time.RFC3339) |
| 888 | } |
| 889 | |
| 890 | // Handle count |
| 891 | count := 20 |
| 892 | if countStr := c.Query("count"); countStr != "" { |
| 893 | if countInt, err := strconv.Atoi(countStr); err == nil { |
| 894 | count = countInt |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | // Get notifications |
| 899 | bskyNotifications, err := blueskyapi.GetMentions(*pds, *oauthToken, count, context) |
| 900 | if err != nil { |
| 901 | return HandleBlueskyError(c, err.Error(), "app.bsky.notification.listNotifications", mentions_timeline) |
| 902 | } |
| 903 | |
| 904 | // Track unique users and posts |
| 905 | uniqueUsers := make(map[string]bool) |
| 906 | uniquePosts := make(map[string]bool) |
| 907 | |
| 908 | // First pass: collect unique users and posts |
| 909 | for _, notification := range bskyNotifications.Notifications { |
| 910 | uniqueUsers[notification.Author.DID] = true |
| 911 | uniquePosts[notification.URI] = true |
| 912 | } |
| 913 | |
| 914 | // Convert maps to slices |
| 915 | usersToLookUp := make([]string, 0, len(uniqueUsers)) |
| 916 | postsToLookUp := make([]string, 0, len(uniquePosts)) |
| 917 | for user := range uniqueUsers { |
| 918 | usersToLookUp = append(usersToLookUp, user) |
| 919 | } |
| 920 | for post := range uniquePosts { |
| 921 | postsToLookUp = append(postsToLookUp, post) |
| 922 | } |
| 923 |
nothing calls this directly
no test coverage detected