Explicitly ignore errors from writes to responses
Some checks failed
/ docker (push) Failing after 15m26s
Some checks failed
/ docker (push) Failing after 15m26s
This commit is contained in:
parent
ef95a0552d
commit
4a2462e24e
30 changed files with 280 additions and 237 deletions
|
@ -35,7 +35,7 @@ func WellKnownWebfinger(w http.ResponseWriter, r *http.Request) {
|
|||
requestedResource := r.FormValue("resource")
|
||||
matches := webfingerResourceRegex.FindStringSubmatch(requestedResource)
|
||||
if len(matches) == 0 {
|
||||
webutils.ProblemDetails(
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"/errors/webfinger-bad-resource",
|
||||
|
@ -56,16 +56,16 @@ func WellKnownWebfinger(w http.ResponseWriter, r *http.Request) {
|
|||
// Fail if requested user is a different domain
|
||||
// TODO: Decide whether to include the info that it's a different domain
|
||||
if domain != config.GlobalConfig.General.GetFullDomain() {
|
||||
webutils.ProblemDetailsStatusOnly(w, 404)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, 404)
|
||||
return
|
||||
}
|
||||
user, err := dbgen.User.GetByUsername(username)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
webutils.ProblemDetailsStatusOnly(w, 404)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, 404)
|
||||
} else {
|
||||
// Fail the request, then attempt to reconnect
|
||||
webutils.ProblemDetails(w, 500, "/errors/db-failure", "internal database failure", nil, nil)
|
||||
_ = webutils.ProblemDetails(w, 500, "/errors/db-failure", "internal database failure", nil, nil)
|
||||
if storage.HandleReconnectError(err) {
|
||||
log.Warn().Msg("Connection to db lost. Reconnect attempt started")
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ func WellKnownWebfinger(w http.ResponseWriter, r *http.Request) {
|
|||
},
|
||||
},
|
||||
}
|
||||
webutils.SendJson(w, &data)
|
||||
_ = webutils.SendJson(w, &data)
|
||||
}
|
||||
|
||||
func NodeInfoOverview(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -117,7 +117,7 @@ func NodeInfoOverview(w http.ResponseWriter, r *http.Request) {
|
|||
},
|
||||
},
|
||||
}
|
||||
webutils.SendJson(w, data)
|
||||
_ = webutils.SendJson(w, data)
|
||||
}
|
||||
|
||||
func NodeInfo21(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -125,7 +125,14 @@ func NodeInfo21(w http.ResponseWriter, r *http.Request) {
|
|||
log := hlog.FromRequest(r)
|
||||
userCount, err := u.Where(u.DeletedAt.IsNull(), u.Verified.Is(true), u.ServerId.Eq(1)).Count()
|
||||
if err != nil {
|
||||
webutils.ProblemDetails(w, 500, "/errors/db-failure", "internal database failure", nil, nil)
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
500,
|
||||
"/errors/db-failure",
|
||||
"internal database failure",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
if storage.HandleReconnectError(err) {
|
||||
log.Warn().Msg("Connection to db lost. Reconnect attempt started")
|
||||
} else {
|
||||
|
@ -136,7 +143,14 @@ func NodeInfo21(w http.ResponseWriter, r *http.Request) {
|
|||
n := dbgen.Note
|
||||
noteCount, err := n.Where(n.DeletedAt.IsNull(), n.OriginId.Eq(1)).Count()
|
||||
if err != nil {
|
||||
webutils.ProblemDetails(w, 500, "/errors/db-failure", "internal database failure", nil, nil)
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
500,
|
||||
"/errors/db-failure",
|
||||
"internal database failure",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
if storage.HandleReconnectError(err) {
|
||||
log.Warn().Msg("Connection to db lost. Reconnect attempt started")
|
||||
} else {
|
||||
|
@ -169,7 +183,7 @@ func NodeInfo21(w http.ResponseWriter, r *http.Request) {
|
|||
LocalComments: 0},
|
||||
Metadata: map[string]any{},
|
||||
}
|
||||
webutils.SendJson(w, data)
|
||||
_ = webutils.SendJson(w, data)
|
||||
}
|
||||
|
||||
func NodeInfo20(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -177,7 +191,14 @@ func NodeInfo20(w http.ResponseWriter, r *http.Request) {
|
|||
log := hlog.FromRequest(r)
|
||||
userCount, err := u.Where(u.DeletedAt.IsNull(), u.Verified.Is(true)).Count()
|
||||
if err != nil {
|
||||
webutils.ProblemDetails(w, 500, "/errors/db-failure", "internal database failure", nil, nil)
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
500,
|
||||
"/errors/db-failure",
|
||||
"internal database failure",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
if storage.HandleReconnectError(err) {
|
||||
log.Warn().Msg("Connection to db lost. Reconnect attempt started")
|
||||
} else {
|
||||
|
@ -188,7 +209,14 @@ func NodeInfo20(w http.ResponseWriter, r *http.Request) {
|
|||
n := dbgen.Note
|
||||
noteCount, err := n.Where(n.DeletedAt.IsNull(), n.OriginId.Eq(1)).Count()
|
||||
if err != nil {
|
||||
webutils.ProblemDetails(w, 500, "/errors/db-failure", "internal database failure", nil, nil)
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
500,
|
||||
"/errors/db-failure",
|
||||
"internal database failure",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
if storage.HandleReconnectError(err) {
|
||||
log.Warn().Msg("Connection to db lost. Reconnect attempt started")
|
||||
} else {
|
||||
|
@ -221,5 +249,5 @@ func NodeInfo20(w http.ResponseWriter, r *http.Request) {
|
|||
Metadata: map[string]any{},
|
||||
}
|
||||
|
||||
webutils.SendJson(w, data)
|
||||
_ = webutils.SendJson(w, data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue