Add helpers to convert between API/internal StatusContentType

This commit is contained in:
ewin 2025-03-03 13:46:05 -05:00
commit 49e649068c
No known key found for this signature in database
2 changed files with 21 additions and 0 deletions

View file

@ -44,6 +44,16 @@ func APIVisToVis(m apimodel.Visibility) gtsmodel.Visibility {
return 0
}
func APIContentTypeToContentType(m apimodel.StatusContentType) gtsmodel.StatusContentType {
switch m {
case apimodel.StatusContentTypePlain:
return gtsmodel.StatusContentTypePlain
case apimodel.StatusContentTypeMarkdown:
return gtsmodel.StatusContentTypeMarkdown
}
return 0
}
func APIMarkerNameToMarkerName(m apimodel.MarkerName) gtsmodel.MarkerName {
switch m {
case apimodel.MarkerNameHome:

View file

@ -1626,6 +1626,17 @@ func (c *Converter) VisToAPIVis(ctx context.Context, m gtsmodel.Visibility) apim
return ""
}
// Converts a gts status content type into its api equivalent
func (c *Converter) ContentTypeToAPIContentType(ctx context.Context, m gtsmodel.StatusContentType) apimodel.StatusContentType {
switch m {
case gtsmodel.StatusContentTypePlain:
return apimodel.StatusContentTypePlain
case gtsmodel.StatusContentTypeMarkdown:
return apimodel.StatusContentTypeMarkdown
}
return ""
}
// InstanceRuleToAdminAPIRule converts a local instance rule into its api equivalent for serving at /api/v1/admin/instance/rules/:id
func InstanceRuleToAPIRule(r gtsmodel.Rule) apimodel.InstanceRule {
return apimodel.InstanceRule{