2023-06-19 17:42:47 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-12-16 14:25:18 -05:00
|
|
|
|
2018-08-25 00:51:50 -04:00
|
|
|
package api // import "miniflux.app/api"
|
2017-12-16 14:25:18 -05:00
|
|
|
|
|
|
|
import (
|
2018-04-29 19:35:04 -04:00
|
|
|
"net/http"
|
2017-12-16 14:25:18 -05:00
|
|
|
|
2018-08-25 00:51:50 -04:00
|
|
|
"miniflux.app/http/request"
|
|
|
|
"miniflux.app/http/response/json"
|
2017-12-16 14:25:18 -05:00
|
|
|
)
|
|
|
|
|
2018-11-11 13:22:47 -05:00
|
|
|
func (h *handler) feedIcon(w http.ResponseWriter, r *http.Request) {
|
2018-09-24 00:02:26 -04:00
|
|
|
feedID := request.RouteInt64Param(r, "feedID")
|
2017-12-16 14:25:18 -05:00
|
|
|
|
2018-11-11 13:22:47 -05:00
|
|
|
if !h.store.HasIcon(feedID) {
|
2018-10-07 21:42:43 -04:00
|
|
|
json.NotFound(w, r)
|
2017-12-16 14:25:18 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-11-11 13:22:47 -05:00
|
|
|
icon, err := h.store.IconByFeedID(request.UserID(r), feedID)
|
2017-12-16 14:25:18 -05:00
|
|
|
if err != nil {
|
2018-10-07 21:42:43 -04:00
|
|
|
json.ServerError(w, r, err)
|
2017-12-16 14:25:18 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if icon == nil {
|
2018-10-07 21:42:43 -04:00
|
|
|
json.NotFound(w, r)
|
2017-12-16 14:25:18 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-13 23:31:19 -05:00
|
|
|
json.OK(w, r, &feedIconResponse{
|
2017-12-16 14:25:18 -05:00
|
|
|
ID: icon.ID,
|
|
|
|
MimeType: icon.MimeType,
|
|
|
|
Data: icon.DataURL(),
|
|
|
|
})
|
|
|
|
}
|