mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-06-27 23:48:23 +00:00
Add support for new gallery link format (#185)
Fixes #183 Reviewed-on: https://codeberg.org/rimgo/rimgo/pulls/185 Co-authored-by: video-prize-ranch <cb.8a3w5@simplelogin.co> Co-committed-by: video-prize-ranch <cb.8a3w5@simplelogin.co>
This commit is contained in:
parent
20715f53af
commit
4afb7cefe7
@ -37,16 +37,21 @@ func HandlePost(c *fiber.Ctx) error {
|
|||||||
utils.SetHeaders(c)
|
utils.SetHeaders(c)
|
||||||
c.Set("X-Frame-Options", "DENY")
|
c.Set("X-Frame-Options", "DENY")
|
||||||
|
|
||||||
|
postId := c.Params("postID")
|
||||||
|
if strings.Contains(postId, "-") {
|
||||||
|
postId = postId[len(postId)-7:]
|
||||||
|
}
|
||||||
|
|
||||||
post, err := api.Album{}, error(nil)
|
post, err := api.Album{}, error(nil)
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(c.Path(), "/a"):
|
case strings.HasPrefix(c.Path(), "/a"):
|
||||||
post, err = ApiClient.FetchAlbum(c.Params("postID"))
|
post, err = ApiClient.FetchAlbum(postId)
|
||||||
case strings.HasPrefix(c.Path(), "/gallery"):
|
case strings.HasPrefix(c.Path(), "/gallery"):
|
||||||
post, err = ApiClient.FetchPosts(c.Params("postID"))
|
post, err = ApiClient.FetchPosts(postId)
|
||||||
case strings.HasPrefix(c.Path(), "/t"):
|
case strings.HasPrefix(c.Path(), "/t"):
|
||||||
post, err = ApiClient.FetchPosts(c.Params("postID"))
|
post, err = ApiClient.FetchPosts(postId)
|
||||||
default:
|
default:
|
||||||
post, err = ApiClient.FetchMedia(c.Params("postID"))
|
post, err = ApiClient.FetchMedia(postId)
|
||||||
}
|
}
|
||||||
if err != nil && err.Error() == "ratelimited by imgur" {
|
if err != nil && err.Error() == "ratelimited by imgur" {
|
||||||
return utils.RenderError(c, 429)
|
return utils.RenderError(c, 429)
|
||||||
@ -61,7 +66,7 @@ func HandlePost(c *fiber.Ctx) error {
|
|||||||
comments := []api.Comment{}
|
comments := []api.Comment{}
|
||||||
if post.SharedWithCommunity {
|
if post.SharedWithCommunity {
|
||||||
c.Set("Cache-Control", "public,max-age=604800")
|
c.Set("Cache-Control", "public,max-age=604800")
|
||||||
comments, err = ApiClient.FetchComments(c.Params("postID"))
|
comments, err = ApiClient.FetchComments(postId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user