2017-12-16 20:25:18 +01:00
|
|
|
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
package api // import "miniflux.app/api"
|
2017-12-16 20:25:18 +01:00
|
|
|
|
|
|
|
import (
|
2018-04-30 01:35:04 +02:00
|
|
|
"net/http"
|
2017-12-16 20:25:18 +01:00
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
"miniflux.app/http/request"
|
|
|
|
"miniflux.app/http/response/json"
|
2017-12-16 20:25:18 +01:00
|
|
|
)
|
|
|
|
|
2018-11-11 19:22:47 +01:00
|
|
|
func (h *handler) feedIcon(w http.ResponseWriter, r *http.Request) {
|
2018-09-24 06:02:26 +02:00
|
|
|
feedID := request.RouteInt64Param(r, "feedID")
|
2017-12-16 20:25:18 +01:00
|
|
|
|
2018-11-11 19:22:47 +01:00
|
|
|
if !h.store.HasIcon(feedID) {
|
2018-10-08 03:42:43 +02:00
|
|
|
json.NotFound(w, r)
|
2017-12-16 20:25:18 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-11-11 19:22:47 +01:00
|
|
|
icon, err := h.store.IconByFeedID(request.UserID(r), feedID)
|
2017-12-16 20:25:18 +01:00
|
|
|
if err != nil {
|
2018-10-08 03:42:43 +02:00
|
|
|
json.ServerError(w, r, err)
|
2017-12-16 20:25:18 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if icon == nil {
|
2018-10-08 03:42:43 +02:00
|
|
|
json.NotFound(w, r)
|
2017-12-16 20:25:18 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-14 05:31:19 +01:00
|
|
|
json.OK(w, r, &feedIconResponse{
|
2017-12-16 20:25:18 +01:00
|
|
|
ID: icon.ID,
|
|
|
|
MimeType: icon.MimeType,
|
|
|
|
Data: icon.DataURL(),
|
|
|
|
})
|
|
|
|
}
|