mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 06:32:26 -05:00
[performance] replace uses of fmt.Sprintf() with inlineable buildURL_() and buildPath_() functions (#4374)
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4374 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
12e3cb71c1
commit
e9b7e977a5
8 changed files with 223 additions and 115 deletions
|
|
@ -185,7 +185,7 @@ func (suite *DereferenceTestSuite) TestDerefLocalStatus() {
|
||||||
"replies": {
|
"replies": {
|
||||||
"first": {
|
"first": {
|
||||||
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true",
|
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true",
|
||||||
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?only_other_accounts=false\u0026page=true",
|
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true\u0026only_other_accounts=false",
|
||||||
"partOf": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies",
|
"partOf": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies",
|
||||||
"type": "CollectionPage"
|
"type": "CollectionPage"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.superseriousbusiness.org/activity/pub"
|
"code.superseriousbusiness.org/activity/pub"
|
||||||
|
|
@ -1042,7 +1043,7 @@ func (c *Converter) MentionToAS(ctx context.Context, m *gtsmodel.Mention) (vocab
|
||||||
domain = m.TargetAccount.Domain
|
domain = m.TargetAccount.Domain
|
||||||
}
|
}
|
||||||
username := m.TargetAccount.Username
|
username := m.TargetAccount.Username
|
||||||
nameString := fmt.Sprintf("@%s@%s", username, domain)
|
nameString := "@" + username + "@" + domain
|
||||||
nameProp := streams.NewActivityStreamsNameProperty()
|
nameProp := streams.NewActivityStreamsNameProperty()
|
||||||
nameProp.AppendXMLSchemaString(nameString)
|
nameProp.AppendXMLSchemaString(nameString)
|
||||||
mention.SetActivityStreamsName(nameProp)
|
mention.SetActivityStreamsName(nameProp)
|
||||||
|
|
@ -1104,7 +1105,7 @@ func (c *Converter) EmojiToAS(ctx context.Context, e *gtsmodel.Emoji) (vocab.Too
|
||||||
emoji.SetJSONLDId(idProp)
|
emoji.SetJSONLDId(idProp)
|
||||||
|
|
||||||
nameProp := streams.NewActivityStreamsNameProperty()
|
nameProp := streams.NewActivityStreamsNameProperty()
|
||||||
nameString := fmt.Sprintf(":%s:", e.Shortcode)
|
nameString := ":" + e.Shortcode + ":"
|
||||||
nameProp.AppendXMLSchemaString(nameString)
|
nameProp.AppendXMLSchemaString(nameString)
|
||||||
emoji.SetActivityStreamsName(nameProp)
|
emoji.SetActivityStreamsName(nameProp)
|
||||||
|
|
||||||
|
|
@ -1490,7 +1491,7 @@ func (c *Converter) BlockToAS(ctx context.Context, b *gtsmodel.Block) (vocab.Act
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
func (c *Converter) StatusToASRepliesCollection(ctx context.Context, status *gtsmodel.Status, onlyOtherAccounts bool) (vocab.ActivityStreamsCollection, error) {
|
func (c *Converter) StatusToASRepliesCollection(ctx context.Context, status *gtsmodel.Status, onlyOtherAccounts bool) (vocab.ActivityStreamsCollection, error) {
|
||||||
collectionID := fmt.Sprintf("%s/replies", status.URI)
|
collectionID := status.URI + "/replies"
|
||||||
collectionIDURI, err := url.Parse(collectionID)
|
collectionIDURI, err := url.Parse(collectionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1509,7 +1510,7 @@ func (c *Converter) StatusToASRepliesCollection(ctx context.Context, status *gts
|
||||||
|
|
||||||
// first.id
|
// first.id
|
||||||
firstPageIDProp := streams.NewJSONLDIdProperty()
|
firstPageIDProp := streams.NewJSONLDIdProperty()
|
||||||
firstPageID, err := url.Parse(fmt.Sprintf("%s?page=true", collectionID))
|
firstPageID, err := url.Parse(collectionID + "?page=true")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, gtserror.NewErrorInternalError(err)
|
return nil, gtserror.NewErrorInternalError(err)
|
||||||
}
|
}
|
||||||
|
|
@ -1518,7 +1519,8 @@ func (c *Converter) StatusToASRepliesCollection(ctx context.Context, status *gts
|
||||||
|
|
||||||
// first.next
|
// first.next
|
||||||
nextProp := streams.NewActivityStreamsNextProperty()
|
nextProp := streams.NewActivityStreamsNextProperty()
|
||||||
nextPropID, err := url.Parse(fmt.Sprintf("%s?only_other_accounts=%t&page=true", collectionID, onlyOtherAccounts))
|
nextPropIDStr := collectionID + "?page=true&only_other_accounts=" + strconv.FormatBool(onlyOtherAccounts)
|
||||||
|
nextPropID, err := url.Parse(nextPropIDStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, gtserror.NewErrorInternalError(err)
|
return nil, gtserror.NewErrorInternalError(err)
|
||||||
}
|
}
|
||||||
|
|
@ -1553,15 +1555,15 @@ func (c *Converter) StatusToASRepliesCollection(ctx context.Context, status *gts
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
func (c *Converter) StatusURIsToASRepliesPage(ctx context.Context, status *gtsmodel.Status, onlyOtherAccounts bool, minID string, replies map[string]*url.URL) (vocab.ActivityStreamsCollectionPage, error) {
|
func (c *Converter) StatusURIsToASRepliesPage(ctx context.Context, status *gtsmodel.Status, onlyOtherAccounts bool, minID string, replies map[string]*url.URL) (vocab.ActivityStreamsCollectionPage, error) {
|
||||||
collectionID := fmt.Sprintf("%s/replies", status.URI)
|
collectionID := status.URI + "/replies"
|
||||||
|
|
||||||
page := streams.NewActivityStreamsCollectionPage()
|
page := streams.NewActivityStreamsCollectionPage()
|
||||||
|
|
||||||
// .id
|
// .id
|
||||||
pageIDProp := streams.NewJSONLDIdProperty()
|
pageIDProp := streams.NewJSONLDIdProperty()
|
||||||
pageIDString := fmt.Sprintf("%s?page=true&only_other_accounts=%t", collectionID, onlyOtherAccounts)
|
pageIDString := collectionID + "?page=true&only_other_accounts=" + strconv.FormatBool(onlyOtherAccounts)
|
||||||
if minID != "" {
|
if minID != "" {
|
||||||
pageIDString = fmt.Sprintf("%s&min_id=%s", pageIDString, minID)
|
pageIDString += "&min_id=" + minID
|
||||||
}
|
}
|
||||||
|
|
||||||
pageID, err := url.Parse(pageIDString)
|
pageID, err := url.Parse(pageIDString)
|
||||||
|
|
@ -1593,9 +1595,9 @@ func (c *Converter) StatusURIsToASRepliesPage(ctx context.Context, status *gtsmo
|
||||||
|
|
||||||
// .next
|
// .next
|
||||||
nextProp := streams.NewActivityStreamsNextProperty()
|
nextProp := streams.NewActivityStreamsNextProperty()
|
||||||
nextPropIDString := fmt.Sprintf("%s?only_other_accounts=%t&page=true", collectionID, onlyOtherAccounts)
|
nextPropIDString := collectionID + "?page=true&only_other_accounts=" + strconv.FormatBool(onlyOtherAccounts)
|
||||||
if highestID != "" {
|
if highestID != "" {
|
||||||
nextPropIDString = fmt.Sprintf("%s&min_id=%s", nextPropIDString, highestID)
|
nextPropIDString += "&min_id=" + minID
|
||||||
}
|
}
|
||||||
|
|
||||||
nextPropID, err := url.Parse(nextPropIDString)
|
nextPropID, err := url.Parse(nextPropIDString)
|
||||||
|
|
@ -1643,12 +1645,12 @@ func (c *Converter) StatusesToASOutboxPage(ctx context.Context, outboxID string,
|
||||||
|
|
||||||
// .id
|
// .id
|
||||||
pageIDProp := streams.NewJSONLDIdProperty()
|
pageIDProp := streams.NewJSONLDIdProperty()
|
||||||
pageID := fmt.Sprintf("%s?page=true", outboxID)
|
pageID := outboxID + "?page=true"
|
||||||
if minID != "" {
|
if minID != "" {
|
||||||
pageID = fmt.Sprintf("%s&minID=%s", pageID, minID)
|
pageID += "&min_id=" + minID
|
||||||
}
|
}
|
||||||
if maxID != "" {
|
if maxID != "" {
|
||||||
pageID = fmt.Sprintf("%s&maxID=%s", pageID, maxID)
|
pageID += "&max_id=" + maxID
|
||||||
}
|
}
|
||||||
pageIDURI, err := url.Parse(pageID)
|
pageIDURI, err := url.Parse(pageID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1691,7 +1693,7 @@ func (c *Converter) StatusesToASOutboxPage(ctx context.Context, outboxID string,
|
||||||
// .next
|
// .next
|
||||||
if lowest != "" {
|
if lowest != "" {
|
||||||
nextProp := streams.NewActivityStreamsNextProperty()
|
nextProp := streams.NewActivityStreamsNextProperty()
|
||||||
nextPropIDString := fmt.Sprintf("%s?page=true&max_id=%s", outboxID, lowest)
|
nextPropIDString := outboxID + "?page=true&max_id=" + lowest
|
||||||
nextPropIDURI, err := url.Parse(nextPropIDString)
|
nextPropIDURI, err := url.Parse(nextPropIDString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1703,7 +1705,7 @@ func (c *Converter) StatusesToASOutboxPage(ctx context.Context, outboxID string,
|
||||||
// .prev
|
// .prev
|
||||||
if highest != "" {
|
if highest != "" {
|
||||||
prevProp := streams.NewActivityStreamsPrevProperty()
|
prevProp := streams.NewActivityStreamsPrevProperty()
|
||||||
prevPropIDString := fmt.Sprintf("%s?page=true&min_id=%s", outboxID, highest)
|
prevPropIDString := outboxID + "?page=true&min_id=" + highest
|
||||||
prevPropIDURI, err := url.Parse(prevPropIDString)
|
prevPropIDURI, err := url.Parse(prevPropIDString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1854,7 +1856,7 @@ func (c *Converter) PollVoteToASCreates(
|
||||||
ap.AppendTo(create, pollAuthorIRI)
|
ap.AppendTo(create, pollAuthorIRI)
|
||||||
|
|
||||||
// Create ID formatted as: {$voterIRI}/activity#vote{$index}/{$statusIRI}.
|
// Create ID formatted as: {$voterIRI}/activity#vote{$index}/{$statusIRI}.
|
||||||
createID := fmt.Sprintf("%s/activity#vote%d/%s", author.URI, i, poll.Status.URI)
|
createID := author.URI + "/activity#vote" + strconv.Itoa(i) + "/" + poll.Status.URI
|
||||||
ap.MustSet(ap.SetJSONLDIdStr, ap.WithJSONLDId(create), createID)
|
ap.MustSet(ap.SetJSONLDIdStr, ap.WithJSONLDId(create), createID)
|
||||||
|
|
||||||
// Set Create actor appropriately.
|
// Set Create actor appropriately.
|
||||||
|
|
@ -1867,7 +1869,7 @@ func (c *Converter) PollVoteToASCreates(
|
||||||
note := streams.NewActivityStreamsNote()
|
note := streams.NewActivityStreamsNote()
|
||||||
|
|
||||||
// For AP IRI generate from author URI + poll ID + vote choice.
|
// For AP IRI generate from author URI + poll ID + vote choice.
|
||||||
id := fmt.Sprintf("%s#%s/votes/%d", author.URI, poll.ID, choice)
|
id := author.URI + "#" + poll.ID + "/votes/" + strconv.Itoa(choice)
|
||||||
ap.MustSet(ap.SetJSONLDIdStr, ap.WithJSONLDId(note), id)
|
ap.MustSet(ap.SetJSONLDIdStr, ap.WithJSONLDId(note), id)
|
||||||
|
|
||||||
// Attach new name property to note with vote choice.
|
// Attach new name property to note with vote choice.
|
||||||
|
|
|
||||||
|
|
@ -600,7 +600,7 @@ func (suite *InternalToASTestSuite) TestStatusToAS() {
|
||||||
"replies": {
|
"replies": {
|
||||||
"first": {
|
"first": {
|
||||||
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true",
|
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true",
|
||||||
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?only_other_accounts=false\u0026page=true",
|
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true\u0026only_other_accounts=false",
|
||||||
"partOf": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies",
|
"partOf": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies",
|
||||||
"type": "CollectionPage"
|
"type": "CollectionPage"
|
||||||
},
|
},
|
||||||
|
|
@ -702,7 +702,7 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASWithIDs() {
|
||||||
"replies": {
|
"replies": {
|
||||||
"first": {
|
"first": {
|
||||||
"id": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?page=true",
|
"id": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?page=true",
|
||||||
"next": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?only_other_accounts=false\u0026page=true",
|
"next": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?page=true\u0026only_other_accounts=false",
|
||||||
"partOf": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies",
|
"partOf": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies",
|
||||||
"type": "CollectionPage"
|
"type": "CollectionPage"
|
||||||
},
|
},
|
||||||
|
|
@ -822,7 +822,7 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASFromDB() {
|
||||||
"replies": {
|
"replies": {
|
||||||
"first": {
|
"first": {
|
||||||
"id": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?page=true",
|
"id": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?page=true",
|
||||||
"next": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?only_other_accounts=false\u0026page=true",
|
"next": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies?page=true\u0026only_other_accounts=false",
|
||||||
"partOf": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies",
|
"partOf": "http://localhost:8080/users/admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R/replies",
|
||||||
"type": "CollectionPage"
|
"type": "CollectionPage"
|
||||||
},
|
},
|
||||||
|
|
@ -927,7 +927,7 @@ func (suite *InternalToASTestSuite) TestStatusToASWithMentions() {
|
||||||
"replies": {
|
"replies": {
|
||||||
"first": {
|
"first": {
|
||||||
"id": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0/replies?page=true",
|
"id": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0/replies?page=true",
|
||||||
"next": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0/replies?only_other_accounts=false\u0026page=true",
|
"next": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0/replies?page=true\u0026only_other_accounts=false",
|
||||||
"partOf": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0/replies",
|
"partOf": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0/replies",
|
||||||
"type": "CollectionPage"
|
"type": "CollectionPage"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func (suite *WrapTestSuite) TestWrapNoteInCreate() {
|
||||||
"replies": {
|
"replies": {
|
||||||
"first": {
|
"first": {
|
||||||
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true",
|
"id": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true",
|
||||||
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?only_other_accounts=false\u0026page=true",
|
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?page=true\u0026only_other_accounts=false",
|
||||||
"partOf": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies",
|
"partOf": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies",
|
||||||
"type": "CollectionPage"
|
"type": "CollectionPage"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
44
internal/uris/helpers.go
Normal file
44
internal/uris/helpers.go
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
// GoToSocial
|
||||||
|
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package uris
|
||||||
|
|
||||||
|
// helper functions for string building that are designed
|
||||||
|
// to be easily inlineable, and much faster than fmt.Sprintf().
|
||||||
|
//
|
||||||
|
// you can check this by ensuring these funcs are not output in:
|
||||||
|
// go build -gcflags='-m=2' ./internal/uris/ 2>&1 | grep 'cannot inline'
|
||||||
|
|
||||||
|
func buildURL1(proto, host, path1 string) string {
|
||||||
|
return proto + "://" + host + "/" + path1
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildURL2(proto, host, path1, path2 string) string {
|
||||||
|
return proto + "://" + host + "/" + path1 + "/" + path2
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildURL4(proto, host, path1, path2, path3, path4 string) string {
|
||||||
|
return proto + "://" + host + "/" + path1 + "/" + path2 + "/" + path3 + "/" + path4
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildURL5(proto, host, path1, path2, path3, path4, path5 string) string {
|
||||||
|
return proto + "://" + host + "/" + path1 + "/" + path2 + "/" + path3 + "/" + path4 + "/" + path5
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildPath4(path1, path2, path3, path4 string) string {
|
||||||
|
return path1 + "/" + path2 + "/" + path3 + "/" + path4
|
||||||
|
}
|
||||||
|
|
@ -50,73 +50,127 @@ const (
|
||||||
RejectsPath = "rejects" // RejectsPath represents the activitypub Reject's location
|
RejectsPath = "rejects" // RejectsPath represents the activitypub Reject's location
|
||||||
)
|
)
|
||||||
|
|
||||||
// UserURIs contains a bunch of UserURIs and URLs for a user, host, account, etc.
|
// UserURIs contains a bunch of UserURIs
|
||||||
|
// and URLs for a user, host, account, etc.
|
||||||
type UserURIs struct {
|
type UserURIs struct {
|
||||||
// The web URL of the instance host, eg https://example.org
|
|
||||||
|
// The web URL of the instance
|
||||||
|
// host, eg https://example.org
|
||||||
HostURL string
|
HostURL string
|
||||||
// The web URL of the user, eg., https://example.org/@example_user
|
|
||||||
|
// The web URL of the user,
|
||||||
|
// eg., https://example.org/@example_user
|
||||||
UserURL string
|
UserURL string
|
||||||
// The web URL for statuses of this user, eg., https://example.org/@example_user/statuses
|
|
||||||
|
// The web URL for statuses of this user,
|
||||||
|
// eg., https://example.org/@example_user/statuses
|
||||||
StatusesURL string
|
StatusesURL string
|
||||||
|
|
||||||
// The activitypub URI of this user, eg., https://example.org/users/example_user
|
// The activitypub URI of this user,
|
||||||
|
// eg., https://example.org/users/example_user
|
||||||
UserURI string
|
UserURI string
|
||||||
// The activitypub URI for this user's statuses, eg., https://example.org/users/example_user/statuses
|
|
||||||
|
// The activitypub URI for this user's statuses,
|
||||||
|
// eg., https://example.org/users/example_user/statuses
|
||||||
StatusesURI string
|
StatusesURI string
|
||||||
// The activitypub URI for this user's activitypub inbox, eg., https://example.org/users/example_user/inbox
|
|
||||||
|
// The activitypub URI for this user's activitypub inbox,
|
||||||
|
// eg., https://example.org/users/example_user/inbox
|
||||||
InboxURI string
|
InboxURI string
|
||||||
// The activitypub URI for this user's activitypub outbox, eg., https://example.org/users/example_user/outbox
|
|
||||||
|
// The activitypub URI for this user's activitypub outbox,
|
||||||
|
// eg., https://example.org/users/example_user/outbox
|
||||||
OutboxURI string
|
OutboxURI string
|
||||||
// The activitypub URI for this user's followers, eg., https://example.org/users/example_user/followers
|
|
||||||
|
// The activitypub URI for this user's followers,
|
||||||
|
// eg., https://example.org/users/example_user/followers
|
||||||
FollowersURI string
|
FollowersURI string
|
||||||
// The activitypub URI for this user's following, eg., https://example.org/users/example_user/following
|
|
||||||
|
// The activitypub URI for this user's following,
|
||||||
|
// eg., https://example.org/users/example_user/following
|
||||||
FollowingURI string
|
FollowingURI string
|
||||||
// The activitypub URI for this user's liked posts eg., https://example.org/users/example_user/liked
|
|
||||||
|
// The activitypub URI for this user's liked posts.
|
||||||
|
// eg., https://example.org/users/example_user/liked
|
||||||
LikedURI string
|
LikedURI string
|
||||||
// The activitypub URI for this user's featured collections, eg., https://example.org/users/example_user/collections/featured
|
|
||||||
|
// The activitypub URI for this user's featured collections,
|
||||||
|
// eg., https://example.org/users/example_user/collections/featured
|
||||||
FeaturedCollectionURI string
|
FeaturedCollectionURI string
|
||||||
// The URI for this user's public key, eg., https://example.org/users/example_user/publickey
|
|
||||||
|
// The URI for this user's public key,
|
||||||
|
// eg., https://example.org/users/example_user/publickey
|
||||||
PublicKeyURI string
|
PublicKeyURI string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForFollow returns the AP URI for a new follow -- something like:
|
// GenerateURIForFollow returns the AP URI for a new follow -- something like:
|
||||||
// https://example.org/users/whatever_user/follow/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user/follow/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForFollow(username string, thisFollowID string) string {
|
func GenerateURIForFollow(username string, thisFollowID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, FollowPath, thisFollowID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
FollowPath,
|
||||||
|
thisFollowID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForLike returns the AP URI for a new like/fave -- something like:
|
// GenerateURIForLike returns the AP URI for a new like/fave -- something like:
|
||||||
// https://example.org/users/whatever_user/liked/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user/liked/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForLike(username string, thisFavedID string) string {
|
func GenerateURIForLike(username string, thisFavedID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, LikedPath, thisFavedID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
LikedPath,
|
||||||
|
thisFavedID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForUpdate returns the AP URI for a new update activity -- something like:
|
// GenerateURIForUpdate returns the AP URI for a new update activity -- something like:
|
||||||
// https://example.org/users/whatever_user#updates/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user#updates/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForUpdate(username string, thisUpdateID string) string {
|
func GenerateURIForUpdate(username string, thisUpdateID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s#%s/%s", protocol, host, UsersPath, username, UpdatePath, thisUpdateID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
UpdatePath,
|
||||||
|
thisUpdateID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForBlock returns the AP URI for a new block activity -- something like:
|
// GenerateURIForBlock returns the AP URI for a new block activity -- something like:
|
||||||
// https://example.org/users/whatever_user/blocks/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user/blocks/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForBlock(username string, thisBlockID string) string {
|
func GenerateURIForBlock(username string, thisBlockID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, BlocksPath, thisBlockID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
BlocksPath,
|
||||||
|
thisBlockID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForMove returns the AP URI for a new Move activity -- something like:
|
// GenerateURIForMove returns the AP URI for a new Move activity -- something like:
|
||||||
// https://example.org/users/whatever_user/moves/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user/moves/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForMove(username string, thisMoveID string) string {
|
func GenerateURIForMove(username string, thisMoveID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, MovesPath, thisMoveID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
MovesPath,
|
||||||
|
thisMoveID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForReport returns the API URI for a new Flag activity -- something like:
|
// GenerateURIForReport returns the API URI for a new Flag activity -- something like:
|
||||||
|
|
@ -125,57 +179,74 @@ func GenerateURIForMove(username string, thisMoveID string) string {
|
||||||
// This path specifically doesn't contain any info about the user who did the reporting,
|
// This path specifically doesn't contain any info about the user who did the reporting,
|
||||||
// to protect their privacy.
|
// to protect their privacy.
|
||||||
func GenerateURIForReport(thisReportID string) string {
|
func GenerateURIForReport(thisReportID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s", protocol, host, ReportsPath, thisReportID)
|
return buildURL2(proto,
|
||||||
|
host,
|
||||||
|
ReportsPath,
|
||||||
|
thisReportID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForEmailConfirm returns a link for email confirmation -- something like:
|
// GenerateURIForEmailConfirm returns a link for email confirmation -- something like:
|
||||||
// https://example.org/confirm_email?token=490e337c-0162-454f-ac48-4b22bb92a205
|
// https://example.org/confirm_email?token=490e337c-0162-454f-ac48-4b22bb92a205
|
||||||
func GenerateURIForEmailConfirm(token string) string {
|
func GenerateURIForEmailConfirm(token string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s?token=%s", protocol, host, ConfirmEmailPath, token)
|
return buildURL1(proto, host, ConfirmEmailPath) + "?token=" + token
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForAccept returns the AP URI for a new Accept activity -- something like:
|
// GenerateURIForAccept returns the AP URI for a new Accept activity -- something like:
|
||||||
// https://example.org/users/whatever_user/accepts/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user/accepts/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForAccept(username string, thisAcceptID string) string {
|
func GenerateURIForAccept(username string, thisAcceptID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, AcceptsPath, thisAcceptID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
AcceptsPath,
|
||||||
|
thisAcceptID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIForReject returns the AP URI for a new Reject activity -- something like:
|
// GenerateURIForReject returns the AP URI for a new Reject activity -- something like:
|
||||||
// https://example.org/users/whatever_user/rejects/01F7XTH1QGBAPMGF49WJZ91XGC
|
// https://example.org/users/whatever_user/rejects/01F7XTH1QGBAPMGF49WJZ91XGC
|
||||||
func GenerateURIForReject(username string, thisRejectID string) string {
|
func GenerateURIForReject(username string, thisRejectID string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s/%s/%s", protocol, host, UsersPath, username, RejectsPath, thisRejectID)
|
return buildURL4(proto,
|
||||||
|
host,
|
||||||
|
UsersPath,
|
||||||
|
username,
|
||||||
|
RejectsPath,
|
||||||
|
thisRejectID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateURIsForAccount throws together a bunch of URIs for the given username, with the given protocol and host.
|
// GenerateURIsForAccount throws together a bunch of URIs
|
||||||
func GenerateURIsForAccount(username string) *UserURIs {
|
// for the given username, with the given protocol and host.
|
||||||
protocol := config.GetProtocol()
|
func GenerateURIsForAccount(username string) UserURIs {
|
||||||
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
|
|
||||||
// The below URLs are used for serving web requests
|
// URLs for serving web requests.
|
||||||
hostURL := fmt.Sprintf("%s://%s", protocol, host)
|
hostURL := proto + "://" + host
|
||||||
userURL := fmt.Sprintf("%s/@%s", hostURL, username)
|
userURL := hostURL + "/@" + username
|
||||||
statusesURL := fmt.Sprintf("%s/%s", userURL, StatusesPath)
|
statusesURL := userURL + "/" + StatusesPath
|
||||||
|
|
||||||
// the below URIs are used in ActivityPub and Webfinger
|
// the below URIs are used in ActivityPub and Webfinger
|
||||||
userURI := fmt.Sprintf("%s/%s/%s", hostURL, UsersPath, username)
|
userURI := hostURL + "/" + UsersPath + "/" + username
|
||||||
statusesURI := fmt.Sprintf("%s/%s", userURI, StatusesPath)
|
statusesURI := userURI + "/" + StatusesPath
|
||||||
inboxURI := fmt.Sprintf("%s/%s", userURI, InboxPath)
|
inboxURI := userURI + "/" + InboxPath
|
||||||
outboxURI := fmt.Sprintf("%s/%s", userURI, OutboxPath)
|
outboxURI := userURI + "/" + OutboxPath
|
||||||
followersURI := fmt.Sprintf("%s/%s", userURI, FollowersPath)
|
followersURI := userURI + "/" + FollowersPath
|
||||||
followingURI := fmt.Sprintf("%s/%s", userURI, FollowingPath)
|
followingURI := userURI + "/" + FollowingPath
|
||||||
likedURI := fmt.Sprintf("%s/%s", userURI, LikedPath)
|
likedURI := userURI + "/" + LikedPath
|
||||||
collectionURI := fmt.Sprintf("%s/%s/%s", userURI, CollectionsPath, FeaturedPath)
|
collectionURI := userURI + "/" + CollectionsPath + "/" + FeaturedPath
|
||||||
publicKeyURI := fmt.Sprintf("%s/%s", userURI, PublicKeyPath)
|
publicKeyURI := userURI + "/" + PublicKeyPath
|
||||||
|
|
||||||
return &UserURIs{
|
return UserURIs{
|
||||||
HostURL: hostURL,
|
HostURL: hostURL,
|
||||||
UserURL: userURL,
|
UserURL: userURL,
|
||||||
StatusesURL: statusesURL,
|
StatusesURL: statusesURL,
|
||||||
|
|
@ -205,19 +276,16 @@ func URIForAttachment(
|
||||||
mediaID string,
|
mediaID string,
|
||||||
extension string,
|
extension string,
|
||||||
) string {
|
) string {
|
||||||
const format = "%s://%s/%s/%s/%s/%s/%s.%s"
|
proto := config.GetProtocol()
|
||||||
|
host := config.GetHost()
|
||||||
return fmt.Sprintf(
|
return buildURL5(proto,
|
||||||
format,
|
host,
|
||||||
config.GetProtocol(),
|
|
||||||
config.GetHost(),
|
|
||||||
FileserverPath,
|
FileserverPath,
|
||||||
accountID,
|
accountID,
|
||||||
mediaType,
|
mediaType,
|
||||||
mediaSize,
|
mediaSize,
|
||||||
mediaID,
|
mediaID,
|
||||||
extension,
|
) + "." + extension
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoragePathForAttachment generates a storage
|
// StoragePathForAttachment generates a storage
|
||||||
|
|
@ -233,16 +301,12 @@ func StoragePathForAttachment(
|
||||||
mediaID string,
|
mediaID string,
|
||||||
extension string,
|
extension string,
|
||||||
) string {
|
) string {
|
||||||
const format = "%s/%s/%s/%s.%s"
|
return buildPath4(
|
||||||
|
|
||||||
return fmt.Sprintf(
|
|
||||||
format,
|
|
||||||
accountID,
|
accountID,
|
||||||
mediaType,
|
mediaType,
|
||||||
mediaSize,
|
mediaSize,
|
||||||
mediaID,
|
mediaID,
|
||||||
extension,
|
) + "." + extension
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// URIForEmoji generates an
|
// URIForEmoji generates an
|
||||||
|
|
@ -252,12 +316,10 @@ func StoragePathForAttachment(
|
||||||
//
|
//
|
||||||
// "https://example.org/emoji/01FPST9QK4V5XWS3F9Z4F2G1X7"
|
// "https://example.org/emoji/01FPST9QK4V5XWS3F9Z4F2G1X7"
|
||||||
func URIForEmoji(emojiID string) string {
|
func URIForEmoji(emojiID string) string {
|
||||||
const format = "%s://%s/%s/%s"
|
proto := config.GetProtocol()
|
||||||
|
host := config.GetHost()
|
||||||
return fmt.Sprintf(
|
return buildURL2(proto,
|
||||||
format,
|
host,
|
||||||
config.GetProtocol(),
|
|
||||||
config.GetHost(),
|
|
||||||
EmojiPath,
|
EmojiPath,
|
||||||
emojiID,
|
emojiID,
|
||||||
)
|
)
|
||||||
|
|
@ -265,9 +327,14 @@ func URIForEmoji(emojiID string) string {
|
||||||
|
|
||||||
// URIForTag generates an activitypub uri for a tag.
|
// URIForTag generates an activitypub uri for a tag.
|
||||||
func URIForTag(name string) string {
|
func URIForTag(name string) string {
|
||||||
protocol := config.GetProtocol()
|
proto := config.GetProtocol()
|
||||||
host := config.GetHost()
|
host := config.GetHost()
|
||||||
return fmt.Sprintf("%s://%s/%s/%s", protocol, host, TagsPath, strings.ToLower(name))
|
name = strings.ToLower(name)
|
||||||
|
return buildURL2(proto,
|
||||||
|
host,
|
||||||
|
TagsPath,
|
||||||
|
name,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsUserPath returns true if the given URL path corresponds to eg /users/example_username
|
// IsUserPath returns true if the given URL path corresponds to eg /users/example_username
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
|
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
|
||||||
|
|
@ -71,7 +71,7 @@ func PackagePageableResponse(params PageableResponseParams) (*apimodel.PageableR
|
||||||
nextRaw := params.NextMaxIDKey + "=" + params.NextMaxIDValue
|
nextRaw := params.NextMaxIDKey + "=" + params.NextMaxIDValue
|
||||||
|
|
||||||
if params.Limit != 0 {
|
if params.Limit != 0 {
|
||||||
nextRaw = fmt.Sprintf("limit=%d&", params.Limit) + nextRaw
|
nextRaw = "limit=" + strconv.Itoa(params.Limit) + "&" + nextRaw
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range params.ExtraQueryParams {
|
for _, p := range params.ExtraQueryParams {
|
||||||
|
|
@ -96,7 +96,7 @@ func PackagePageableResponse(params PageableResponseParams) (*apimodel.PageableR
|
||||||
prevRaw := params.PrevMinIDKey + "=" + params.PrevMinIDValue
|
prevRaw := params.PrevMinIDKey + "=" + params.PrevMinIDValue
|
||||||
|
|
||||||
if params.Limit != 0 {
|
if params.Limit != 0 {
|
||||||
prevRaw = fmt.Sprintf("limit=%d&", params.Limit) + prevRaw
|
prevRaw = "limit=" + strconv.Itoa(params.Limit) + "&" + prevRaw
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range params.ExtraQueryParams {
|
for _, p := range params.ExtraQueryParams {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ package webpush
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
@ -299,41 +298,37 @@ func formatNotificationTitle(
|
||||||
|
|
||||||
switch notification.NotificationType {
|
switch notification.NotificationType {
|
||||||
case gtsmodel.NotificationFollow:
|
case gtsmodel.NotificationFollow:
|
||||||
return fmt.Sprintf("%s followed you", displayNameOrAcct)
|
return displayNameOrAcct + " followed you"
|
||||||
case gtsmodel.NotificationFollowRequest:
|
case gtsmodel.NotificationFollowRequest:
|
||||||
return fmt.Sprintf("%s requested to follow you", displayNameOrAcct)
|
return displayNameOrAcct + " requested to followed you"
|
||||||
case gtsmodel.NotificationMention:
|
case gtsmodel.NotificationMention:
|
||||||
return fmt.Sprintf("%s mentioned you", displayNameOrAcct)
|
return displayNameOrAcct + " mentioned you"
|
||||||
case gtsmodel.NotificationReblog:
|
case gtsmodel.NotificationReblog:
|
||||||
return fmt.Sprintf("%s boosted your post", displayNameOrAcct)
|
return displayNameOrAcct + " boosted your post"
|
||||||
case gtsmodel.NotificationFavourite:
|
case gtsmodel.NotificationFavourite:
|
||||||
return fmt.Sprintf("%s faved your post", displayNameOrAcct)
|
return displayNameOrAcct + " faved your post"
|
||||||
case gtsmodel.NotificationPoll:
|
case gtsmodel.NotificationPoll:
|
||||||
if subscription.AccountID == notification.TargetAccountID {
|
if subscription.AccountID == notification.TargetAccountID {
|
||||||
return "Your poll has ended"
|
return "Your poll has ended"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s's poll has ended", displayNameOrAcct)
|
return displayNameOrAcct + "'s poll has ended"
|
||||||
case gtsmodel.NotificationStatus:
|
case gtsmodel.NotificationStatus:
|
||||||
return fmt.Sprintf("%s posted", displayNameOrAcct)
|
return displayNameOrAcct + " posted"
|
||||||
case gtsmodel.NotificationAdminSignup:
|
case gtsmodel.NotificationAdminSignup:
|
||||||
return fmt.Sprintf("%s requested to sign up", displayNameOrAcct)
|
return displayNameOrAcct + " requested to sign up"
|
||||||
case gtsmodel.NotificationPendingFave:
|
case gtsmodel.NotificationPendingFave:
|
||||||
return fmt.Sprintf("%s faved your post, which requires your approval", displayNameOrAcct)
|
return displayNameOrAcct + " faved your post, which requires your approval"
|
||||||
case gtsmodel.NotificationPendingReply:
|
case gtsmodel.NotificationPendingReply:
|
||||||
return fmt.Sprintf("%s mentioned you, which requires your approval", displayNameOrAcct)
|
return displayNameOrAcct + " mentioned you, which requires your approval"
|
||||||
case gtsmodel.NotificationPendingReblog:
|
case gtsmodel.NotificationPendingReblog:
|
||||||
return fmt.Sprintf("%s boosted your post, which requires your approval", displayNameOrAcct)
|
return displayNameOrAcct + " boosted your post, which requires your approval"
|
||||||
case gtsmodel.NotificationAdminReport:
|
case gtsmodel.NotificationAdminReport:
|
||||||
return fmt.Sprintf("%s submitted a report", displayNameOrAcct)
|
return displayNameOrAcct + " submitted a report"
|
||||||
case gtsmodel.NotificationUpdate:
|
case gtsmodel.NotificationUpdate:
|
||||||
return fmt.Sprintf("%s updated their post", displayNameOrAcct)
|
return displayNameOrAcct + " updated their post"
|
||||||
default:
|
default:
|
||||||
log.Warnf(ctx, "Unknown notification type: %d", notification.NotificationType)
|
log.Warnf(ctx, "Unknown notification type: %d", notification.NotificationType)
|
||||||
return fmt.Sprintf(
|
return displayNameOrAcct + " did something (unknown notification type)"
|
||||||
"%s did something (unknown notification type %d)",
|
|
||||||
displayNameOrAcct,
|
|
||||||
notification.NotificationType,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue