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

Function UserProfileImage

twitterv1/cdnproxy.go:160–194  ·  view source on GitHub ↗
(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

158}
159
160func UserProfileImage(c *fiber.Ctx) error {
161 // auth
162 _, pds, _, oauthToken, err := GetAuthFromReq(c)
163
164 if err != nil {
165 blankstring := ""
166 oauthToken = &blankstring
167 }
168
169 screen_name := c.Query("screen_name")
170 if screen_name == "" {
171 return c.Status(fiber.StatusBadRequest).SendString("screen_name is required")
172 }
173 // size := c.Query("size")
174 // if size == "" {
175 // size = "normal"
176 // }
177 // cdn_size := ":profile_bigger"
178
179 // switch size {
180 // case "normal":
181 // cdn_size = ":profile_normal"
182 // case "original":
183 // cdn_size = ":large"
184 // }
185
186 userinfo, err := blueskyapi.GetUserInfo(*pds, *oauthToken, screen_name, false)
187 if err != nil {
188 return c.Status(fiber.StatusInternalServerError).SendString("Failed to fetch user info")
189 }
190
191 //c.Redirect("https://cdn.bsky.app/img/" + screen_name + ":profile_bigger")
192 c.Set("Cache-Control", "public, max-age=900") // 15 minutes
193 return c.Redirect(userinfo.ProfileImageURL)
194}
195
196// This is here because it doesn't just want a direct link to the m3u8 file.
197// So we make an extremely basic site that just includes the video, and maybe the alt text if i care enough

Callers

nothing calls this directly

Calls 2

GetAuthFromReqFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected