feat: add ImageHandler and ImageService for image retrieval from channels

This commit is contained in:
2026-03-13 17:18:08 +03:30
parent 71a2c756c2
commit 7aab3f55ed
8 changed files with 189 additions and 12 deletions
+4 -2
View File
@@ -25,6 +25,7 @@ type RouterParams struct {
ChannelHandler *handlers.ChannelHandler
AuthHandler *handlers.AuthHandler
ImageHandler *handlers.ImageHandler
}
func NewGin() *gin.Engine {
@@ -47,12 +48,13 @@ func RegisterRoutes(params RouterParams) {
})
})
// params.GinEngine.GET("/feed/:id/json", params.ChannelHandler.GetMessagesJson)
params.GinEngine.GET("/feed/:id/json", params.ChannelHandler.GetMessagesJson)
params.GinEngine.GET("/feed/:id", params.RateLimiter.RateLimit(), params.ChannelHandler.GetMessagesRSS)
params.GinEngine.GET("/image/:channelId/:messageId", params.ImageHandler.GetImage)
// TODO: improve accurecy in rss channel fields
// TODO: add ui with templates under /setup with fetch
// TODO: image endpoint + hash and expiry
// TODO: image endpoint + HMAC
authStatCtx, cancel := context.WithTimeout(context.Background(), config.AuthStatusTimeout)
authStat, err := params.TgService.AuthStatus(authStatCtx)
cancel()
+1
View File
@@ -11,6 +11,7 @@ import (
"golang.org/x/time/rate"
)
// TODO: another limiter rate for images
type ClientLimiter struct {
limiter *rate.Limiter
lastSeen time.Time