Skip to content

Commit

Permalink
Merge pull request #3585 from bluesky-social/download_url
Browse files Browse the repository at this point in the history
Add a handler for /download that directs you to the device-appropriat…
  • Loading branch information
ericvolp12 authored Apr 16, 2024
2 parents 8864e9a + 09e1f0e commit 4a771b9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bskyweb/cmd/bskyweb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ func serve(cctx *cli.Context) error {
// home
e.GET("/", server.WebHome)

// download
e.GET("/download", server.Download)

// generic routes
e.GET("/hashtag/:tag", server.WebGeneric)
e.GET("/search", server.WebGeneric)
Expand Down Expand Up @@ -271,6 +274,20 @@ func (srv *Server) errorHandler(err error, c echo.Context) {
c.Render(code, "error.html", data)
}

// Handler for redirecting to the download page.
func (srv *Server) Download(c echo.Context) error {
ua := c.Request().UserAgent()
if strings.Contains(ua, "Android") {
return c.Redirect(http.StatusFound, "https://play.google.com/store/apps/details?id=xyz.blueskyweb.app")
}

if strings.Contains(ua, "iPhone") || strings.Contains(ua, "iPad") || strings.Contains(ua, "iPod") {
return c.Redirect(http.StatusFound, "https://apps.apple.com/tr/app/bluesky-social/id6444370199")
}

return c.Redirect(http.StatusFound, "/")
}

// handler for endpoint that have no specific server-side handling
func (srv *Server) WebGeneric(c echo.Context) error {
data := pongo2.Context{}
Expand Down

0 comments on commit 4a771b9

Please sign in to comment.