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
|
@ -17,7 +17,7 @@ func handleUndo(w http.ResponseWriter, r *http.Request, object map[string]any) {
|
|||
_ = object["id"].(string)
|
||||
_, ok := object["actor"].(string)
|
||||
if !ok {
|
||||
webutils.ProblemDetails(
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"/errors/bad-request-data",
|
||||
|
@ -29,7 +29,7 @@ func handleUndo(w http.ResponseWriter, r *http.Request, object map[string]any) {
|
|||
}
|
||||
rawTarget, ok := object["object"]
|
||||
if !ok {
|
||||
webutils.ProblemDetails(
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"/errors/bad-request-data",
|
||||
|
@ -49,7 +49,7 @@ func handleUndo(w http.ResponseWriter, r *http.Request, object map[string]any) {
|
|||
case map[string]any:
|
||||
objType, ok := target["type"].(string)
|
||||
if !ok {
|
||||
webutils.ProblemDetails(
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"/errors/bad-request-data",
|
||||
|
@ -62,7 +62,7 @@ func handleUndo(w http.ResponseWriter, r *http.Request, object map[string]any) {
|
|||
targetObjectType = objType
|
||||
targetObjectId, ok = target["id"].(string)
|
||||
if !ok {
|
||||
webutils.ProblemDetails(
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"/errors/bad-request-data",
|
||||
|
@ -73,7 +73,7 @@ func handleUndo(w http.ResponseWriter, r *http.Request, object map[string]any) {
|
|||
return
|
||||
}
|
||||
default:
|
||||
webutils.ProblemDetails(
|
||||
_ = webutils.ProblemDetails(
|
||||
w,
|
||||
http.StatusBadRequest,
|
||||
"/errors/bad-request-data",
|
||||
|
@ -92,7 +92,7 @@ func handleUndo(w http.ResponseWriter, r *http.Request, object map[string]any) {
|
|||
log.Error().
|
||||
Str("undo-target-type", targetObjectType).
|
||||
Msg("Unknown/unimplemented undo target type")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ func undoLike(w http.ResponseWriter, r *http.Request, object map[string]any, tar
|
|||
Err(err).
|
||||
Str("activity-id", targetId).
|
||||
Msg("Error while looking for like activity")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
reactionId := uint(other.Must(strconv.ParseUint(act.ObjectId, 10, 64)))
|
||||
|
@ -123,7 +123,7 @@ func undoLike(w http.ResponseWriter, r *http.Request, object map[string]any, tar
|
|||
Err(err).
|
||||
Str("activity-id", targetId).
|
||||
Msg("Error while looking for find activity")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
tx := dbgen.Q.Begin()
|
||||
|
@ -131,7 +131,7 @@ func undoLike(w http.ResponseWriter, r *http.Request, object map[string]any, tar
|
|||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
log.Error().Err(err).Str("activity-id", act.Id).Msg("Failed to delete activity on undo")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
_, err = tx.Reaction.Where(dbgen.Reaction.ID.Eq(reaction.ID)).Delete()
|
||||
|
@ -141,13 +141,13 @@ func undoLike(w http.ResponseWriter, r *http.Request, object map[string]any, tar
|
|||
Err(err).
|
||||
Uint("reaction-id", reaction.ID).
|
||||
Msg("Failed to delete reaction on undo")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to delete reaction and activity")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ func undoFollow(w http.ResponseWriter, r *http.Request, object map[string]any, t
|
|||
Err(err).
|
||||
Str("activity-id", targetId).
|
||||
Msg("Error while looking for follow activity")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
relationId := other.Must(strconv.ParseUint(act.ObjectId, 10, 64))
|
||||
|
@ -176,7 +176,7 @@ func undoFollow(w http.ResponseWriter, r *http.Request, object map[string]any, t
|
|||
Err(err).
|
||||
Str("activity-id", act.Id).
|
||||
Msg("Failed to delete follow activity on undo")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
// Delete all activities that reference the follow activity (so accept/reject if exists)
|
||||
|
@ -187,7 +187,7 @@ func undoFollow(w http.ResponseWriter, r *http.Request, object map[string]any, t
|
|||
Err(err).
|
||||
Str("activity-id", act.Id).
|
||||
Msg("Failed to delete accept/reject activity for follow on undo")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
_, err = tx.UserToUserRelation.Where(dbgen.UserToUserRelation.ID.Eq(relationId)).Delete()
|
||||
|
@ -198,12 +198,12 @@ func undoFollow(w http.ResponseWriter, r *http.Request, object map[string]any, t
|
|||
Str("activity-id", act.Id).
|
||||
Uint64("relation-id", relationId).
|
||||
Msg("Failed to delete user-to-user relation for follow on undo")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to delete reaction and activity")
|
||||
webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
_ = webutils.ProblemDetailsStatusOnly(w, http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue