start refactoring return codes from fedi endpoints, remove some cruft

This commit is contained in:
tobi 2025-10-08 13:14:06 +02:00
commit 47051a26d6
28 changed files with 346 additions and 291 deletions

View file

@ -217,17 +217,21 @@ func (f *Federator) AuthenticatePostInbox(ctx context.Context, w http.ResponseWr
pubKeyAuth, errWithCode := f.AuthenticateFederatedRequest(ctx, receivingAccount.Username)
if errWithCode != nil {
switch errWithCode.Code() {
case http.StatusUnauthorized, http.StatusForbidden, http.StatusBadRequest:
// If codes 400, 401, or 403, obey the go-fed
// interface by writing the header and bailing.
// If codes 400, 401, or 403, obey the go-fed
// interface by writing the header and bailing.
case http.StatusUnauthorized,
http.StatusForbidden,
http.StatusBadRequest:
w.WriteHeader(errWithCode.Code())
// If the requesting account's key has gone
// (410) then likely inbox post was a Delete.
//
// We can just write 202 and leave: we didn't
// know about the account anyway, so we can't
// do any further processing.
case http.StatusGone:
// If the requesting account's key has gone
// (410) then likely inbox post was a delete.
//
// We can just write 202 and leave: we didn't
// know about the account anyway, so we can't
// do any further processing.
w.WriteHeader(http.StatusAccepted)
}