summaryrefslogtreecommitdiff
path: root/internal/typeutils
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-07-12 20:36:03 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-12 20:36:03 +0200
commitaeb65bceae97611b8931de2e954df18afedd812f (patch)
tree74e6f7ecb86c8affcfef99994cbf21d9133a2b56 /internal/typeutils
parent[feature] support processing of (many) more media types (#3090) (diff)
downloadgotosocial-aeb65bceae97611b8931de2e954df18afedd812f.tar.xz
[feature/frontend] Better visual separation between "main" thread and "replies" (#3093)
* [feature/frontend] Better web threading model * fix test * bwap * tweaks * more tweaks to wording * typo * indenting * adjust wording * aaa
Diffstat (limited to 'internal/typeutils')
-rw-r--r--internal/typeutils/internaltofrontend.go23
-rw-r--r--internal/typeutils/internaltofrontend_test.go10
2 files changed, 24 insertions, 9 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index c0cd3d7e7..9d99205f6 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -982,13 +982,23 @@ func filterAppliesInContext(filter *gtsmodel.Filter, filterContext statusfilter.
func (c *Converter) StatusToWebStatus(
ctx context.Context,
s *gtsmodel.Status,
- requestingAccount *gtsmodel.Account,
-) (*apimodel.Status, error) {
- webStatus, err := c.statusToFrontend(ctx, s, requestingAccount, statusfilter.FilterContextNone, nil, nil)
+) (*apimodel.WebStatus, error) {
+ apiStatus, err := c.statusToFrontend(
+ ctx,
+ s,
+ nil, // No authed requester.
+ statusfilter.FilterContextNone,
+ nil, // No filters.
+ nil, // No mutes.
+ )
if err != nil {
return nil, err
}
+ webStatus := &apimodel.WebStatus{
+ Status: apiStatus,
+ }
+
// Whack a newline before and after each "pre" to make it easier to outdent it.
webStatus.Content = strings.ReplaceAll(webStatus.Content, "<pre>", "\n<pre>")
webStatus.Content = strings.ReplaceAll(webStatus.Content, "</pre>", "</pre>\n")
@@ -1014,7 +1024,7 @@ func (c *Converter) StatusToWebStatus(
// format them for easier template consumption.
totalVotes := poll.VotesCount
- webPollOptions := make([]apimodel.WebPollOption, len(poll.Options))
+ PollOptions := make([]apimodel.WebPollOption, len(poll.Options))
for i, option := range poll.Options {
var voteShare float32
@@ -1046,10 +1056,10 @@ func (c *Converter) StatusToWebStatus(
VoteShare: voteShare,
VoteShareStr: voteShareStr,
}
- webPollOptions[i] = webPollOption
+ PollOptions[i] = webPollOption
}
- webStatus.WebPollOptions = webPollOptions
+ webStatus.PollOptions = PollOptions
}
// Set additional templating
@@ -1058,6 +1068,7 @@ func (c *Converter) StatusToWebStatus(
a.Sensitive = webStatus.Sensitive
}
+ // Mark this as a local status.
webStatus.Local = *s.Local
return webStatus, nil
diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go
index 1195bc137..9ad5d2c08 100644
--- a/internal/typeutils/internaltofrontend_test.go
+++ b/internal/typeutils/internaltofrontend_test.go
@@ -883,9 +883,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments
func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() {
testStatus := suite.testStatuses["remote_account_2_status_1"]
- requestingAccount := suite.testAccounts["admin_account"]
- apiStatus, err := suite.typeconverter.StatusToWebStatus(context.Background(), testStatus, requestingAccount)
+ apiStatus, err := suite.typeconverter.StatusToWebStatus(context.Background(), testStatus)
suite.NoError(err)
// MediaAttachments should inherit
@@ -1010,7 +1009,12 @@ func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() {
"tags": [],
"emojis": [],
"card": null,
- "poll": null
+ "poll": null,
+ "LanguageTag": "en",
+ "PollOptions": null,
+ "Local": false,
+ "Indent": 0,
+ "ThreadFirstReply": false
}`, string(b))
}