[feature] Hashtag federation (in/out), hashtag client API endpoints (#2032)

* update go-fed

* do the things

* remove unused columns from tags

* update to latest lingo from main

* further tag shenanigans

* serve stub page at tag endpoint

* we did it lads

* tests, oh tests, ohhh tests, oh tests (doo doo doo doo)

* swagger docs

* document hashtag usage + federation

* instanceGet

* don't bother parsing tag href

* rename whereStartsWith -> whereStartsLike

* remove GetOrCreateTag

* dont cache status tag timelineability
This commit is contained in:
tobi
2023-07-31 15:47:35 +02:00
committed by GitHub
parent ed2477ebea
commit 2796a2e82f
69 changed files with 2536 additions and 482 deletions

View File

@@ -20,11 +20,18 @@ package util
import (
"fmt"
"strconv"
"strings"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
)
const (
/* API version keys */
APIVersionKey = "api_version"
APIv1 = "v1"
APIv2 = "v2"
/* Common keys */
IDKey = "id"
@@ -44,6 +51,10 @@ const (
SearchResolveKey = "resolve"
SearchTypeKey = "type"
/* Tag keys */
TagNameKey = "tag_name"
/* Web endpoint keys */
WebUsernameKey = "username"
@@ -122,6 +133,26 @@ func ParseDomainBlockImport(value string, defaultValue bool) (bool, gtserror.Wit
Parse functions for *REQUIRED* parameters.
*/
func ParseAPIVersion(value string, availableVersion ...string) (string, gtserror.WithCode) {
key := APIVersionKey
if value == "" {
return "", requiredError(key)
}
for _, av := range availableVersion {
if value == av {
return value, nil
}
}
err := fmt.Errorf(
"invalid API version, valid versions for this path are [%s]",
strings.Join(availableVersion, ", "),
)
return "", gtserror.NewErrorBadRequest(err, err.Error())
}
func ParseID(value string) (string, gtserror.WithCode) {
key := IDKey
@@ -152,6 +183,16 @@ func ParseSearchQuery(value string) (string, gtserror.WithCode) {
return value, nil
}
func ParseTagName(value string) (string, gtserror.WithCode) {
key := TagNameKey
if value == "" {
return "", requiredError(key)
}
return value, nil
}
func ParseWebUsername(value string) (string, gtserror.WithCode) {
key := WebUsernameKey