Merge branch 'main' into content_warning_fixes

This commit is contained in:
tobi 2025-03-07 10:52:56 +01:00
commit aa5713fc38
26 changed files with 572 additions and 26 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

@ -1395,6 +1395,7 @@ func (c *Converter) baseStatusToFrontend(
Emojis: apiEmojis,
Card: nil, // TODO: implement cards
Text: s.Text,
ContentType: ContentTypeToAPIContentType(s.ContentType),
InteractionPolicy: *apiInteractionPolicy,
}
@ -1630,6 +1631,17 @@ func (c *Converter) VisToAPIVis(ctx context.Context, m gtsmodel.Visibility) apim
return ""
}
// Converts a gts status content type into its api equivalent
func ContentTypeToAPIContentType(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{

View file

@ -725,6 +725,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendHTMLContentWarning
"card": null,
"poll": null,
"text": "hello world! #welcome ! first post on the instance :rainbow: !",
"content_type": "text/plain",
"interaction_policy": {
"can_favourite": {
"always": [
@ -905,6 +906,7 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() {
"card": null,
"poll": null,
"text": "hello world! #welcome ! first post on the instance :rainbow: ! fnord",
"content_type": "text/plain",
"filtered": [
{
"filter": {
@ -1090,6 +1092,7 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() {
"card": null,
"poll": null,
"text": "hello world! #welcome ! first post on the instance :rainbow: ! fnord",
"content_type": "text/plain",
"filtered": [
{
"filter": {
@ -1823,6 +1826,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage()
"card": null,
"poll": null,
"text": "hello world! #welcome ! first post on the instance :rainbow: !",
"content_type": "text/plain",
"interaction_policy": {
"can_favourite": {
"always": [
@ -1921,6 +1925,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendPartialInteraction
"card": null,
"poll": null,
"text": "this is a very personal post that I don't want anyone to interact with at all, and i only want mutuals to see it",
"content_type": "text/plain",
"interaction_policy": {
"can_favourite": {
"always": [
@ -2044,6 +2049,7 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval()
"card": null,
"poll": null,
"text": "Hi @1happyturtle, can I reply?",
"content_type": "text/markdown",
"interaction_policy": {
"can_favourite": {
"always": [
@ -3522,6 +3528,7 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
"card": null,
"poll": null,
"text": "🐢 i don't mind people sharing and liking this one but I want to moderate replies to it 🐢",
"content_type": "text/plain",
"interaction_policy": {
"can_favourite": {
"always": [
@ -3620,6 +3627,7 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
"card": null,
"poll": null,
"text": "Hi @1happyturtle, can I reply?",
"content_type": "text/markdown",
"interaction_policy": {
"can_favourite": {
"always": [
@ -3779,6 +3787,7 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
"card": null,
"poll": null,
"text": "hello everyone!",
"content_type": "text/plain",
"interaction_policy": {
"can_favourite": {
"always": [
@ -3948,6 +3957,7 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
"card": null,
"poll": null,
"text": "hello everyone!",
"content_type": "text/plain",
"interaction_policy": {
"can_favourite": {
"always": [