mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 01:46:16 -06:00
Add helpers to convert between API/internal StatusContentType
This commit is contained in:
parent
da31c5c617
commit
49e649068c
2 changed files with 21 additions and 0 deletions
|
|
@ -44,6 +44,16 @@ func APIVisToVis(m apimodel.Visibility) gtsmodel.Visibility {
|
||||||
return 0
|
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 {
|
func APIMarkerNameToMarkerName(m apimodel.MarkerName) gtsmodel.MarkerName {
|
||||||
switch m {
|
switch m {
|
||||||
case apimodel.MarkerNameHome:
|
case apimodel.MarkerNameHome:
|
||||||
|
|
|
||||||
|
|
@ -1626,6 +1626,17 @@ func (c *Converter) VisToAPIVis(ctx context.Context, m gtsmodel.Visibility) apim
|
||||||
return ""
|
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
|
// 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 {
|
func InstanceRuleToAPIRule(r gtsmodel.Rule) apimodel.InstanceRule {
|
||||||
return apimodel.InstanceRule{
|
return apimodel.InstanceRule{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue