Files
kim b0863b60e1 [feature] add a status visibility debug endpoint (#4682)
- adds a debug endpoint for debugging why a status may or may not be visible to you, with relevant swagger docs
- updates apiutil.NegotiateAccept() to return an errWithCode to reduce a tonne of repeated code

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4682
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
2026-02-10 14:36:03 +01:00

79 lines
2.2 KiB
Go

// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package instance
import (
"net/http"
apiutil "code.superseriousbusiness.org/gotosocial/internal/api/util"
"github.com/gin-gonic/gin"
)
// instanceRulesGETHandler swagger:operation GET /api/v1/instance/rules rules
//
// View instance rules (public).
//
// The rules will be returned in order (sorted by Order ascending).
//
// ---
// tags:
// - instance
//
// produces:
// - application/json
//
// parameters:
//
// responses:
// '200':
// description: An array with all the rules for the local instance.
// schema:
// type: array
// items:
// "$ref": "#/definitions/instanceRule"
// '400':
// schema:
// "$ref": "#/definitions/error"
// description: bad request
// '404':
// schema:
// "$ref": "#/definitions/error"
// description: not found
// '406':
// schema:
// "$ref": "#/definitions/error"
// description: not acceptable
// '500':
// schema:
// "$ref": "#/definitions/error"
// description: internal server error
func (m *Module) InstanceRulesGETHandler(c *gin.Context) {
if _, errWithCode := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return
}
resp, errWithCode := m.processor.InstanceGetRules(c.Request.Context())
if errWithCode != nil {
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
return
}
apiutil.JSON(c, http.StatusOK, resp)
}