summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/account/create.go9
-rw-r--r--internal/processing/account/delete.go15
-rw-r--r--internal/processing/account/update.go9
-rw-r--r--internal/processing/admin/createdomainblock.go11
-rw-r--r--internal/processing/admin/importdomainblocks.go2
-rw-r--r--internal/processing/admin/mediaprune.go14
-rw-r--r--internal/processing/fromclientapi.go21
-rw-r--r--internal/processing/fromfederator.go34
-rw-r--r--internal/processing/media/getemoji.go4
-rw-r--r--internal/processing/notification.go7
-rw-r--r--internal/processing/search.go21
-rw-r--r--internal/processing/status/util.go6
-rw-r--r--internal/processing/status/util_test.go11
-rw-r--r--internal/processing/statustimeline.go21
-rw-r--r--internal/processing/streaming/openstream.go13
15 files changed, 114 insertions, 84 deletions
diff --git a/internal/processing/account/create.go b/internal/processing/account/create.go
index 44d6bbea5..e6cb44ce8 100644
--- a/internal/processing/account/create.go
+++ b/internal/processing/account/create.go
@@ -22,21 +22,18 @@ import (
"context"
"fmt"
- "github.com/sirupsen/logrus"
-
"github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/text"
"github.com/superseriousbusiness/oauth2/v4"
)
func (p *processor) Create(ctx context.Context, applicationToken oauth2.TokenInfo, application *gtsmodel.Application, form *apimodel.AccountCreateRequest) (*apimodel.Token, gtserror.WithCode) {
- l := logrus.WithField("func", "accountCreate")
-
emailAvailable, err := p.db.IsEmailAvailable(ctx, form.Email)
if err != nil {
return nil, gtserror.NewErrorBadRequest(err)
@@ -62,13 +59,13 @@ func (p *processor) Create(ctx context.Context, applicationToken oauth2.TokenInf
reason = ""
}
- l.Trace("creating new username and account")
+ log.Trace("creating new username and account")
user, err := p.db.NewSignup(ctx, form.Username, text.SanitizePlaintext(reason), approvalRequired, form.Email, form.Password, form.IP, form.Locale, application.ID, false, false)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error creating new signup in the database: %s", err))
}
- l.Tracef("generating a token for user %s with account %s and application %s", user.ID, user.AccountID, application.ID)
+ log.Tracef("generating a token for user %s with account %s and application %s", user.ID, user.AccountID, application.ID)
accessToken, err := p.oauthServer.GenerateUserAccessToken(ctx, applicationToken, application.ClientSecret, user.ID)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error creating new access token for user %s: %s", user.ID, err))
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go
index 67192cb8f..7b382f17c 100644
--- a/internal/processing/account/delete.go
+++ b/internal/processing/account/delete.go
@@ -23,12 +23,13 @@ import (
"errors"
"time"
- "github.com/sirupsen/logrus"
+ "codeberg.org/gruf/go-kv"
"github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"golang.org/x/crypto/bcrypt"
)
@@ -55,14 +56,16 @@ import (
// 17. Delete account's timeline
// 18. Delete account itself
func (p *processor) Delete(ctx context.Context, account *gtsmodel.Account, origin string) gtserror.WithCode {
- fields := logrus.Fields{
- "func": "Delete",
- "username": account.Username,
+ fields := kv.Fields{
+
+ {"username", account.Username},
}
if account.Domain != "" {
- fields["domain"] = account.Domain
+ fields = append(fields, kv.Field{
+ "domain", account.Domain,
+ })
}
- l := logrus.WithFields(fields)
+ l := log.WithFields(fields...)
l.Debug("beginning account delete process")
diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go
index d1085845b..78791dcce 100644
--- a/internal/processing/account/update.go
+++ b/internal/processing/account/update.go
@@ -24,13 +24,12 @@ import (
"io"
"mime/multipart"
- "github.com/sirupsen/logrus"
-
"github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/text"
@@ -39,8 +38,6 @@ import (
)
func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form *apimodel.UpdateCredentialsRequest) (*apimodel.Account, gtserror.WithCode) {
- l := logrus.WithField("func", "AccountUpdate")
-
if form.Discoverable != nil {
account.Discoverable = *form.Discoverable
}
@@ -81,7 +78,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form
}
account.AvatarMediaAttachmentID = avatarInfo.ID
account.AvatarMediaAttachment = avatarInfo
- l.Tracef("new avatar info for account %s is %+v", account.ID, avatarInfo)
+ log.Tracef("new avatar info for account %s is %+v", account.ID, avatarInfo)
}
if form.Header != nil && form.Header.Size != 0 {
@@ -91,7 +88,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form
}
account.HeaderMediaAttachmentID = headerInfo.ID
account.HeaderMediaAttachment = headerInfo
- l.Tracef("new header info for account %s is %+v", account.ID, headerInfo)
+ log.Tracef("new header info for account %s is %+v", account.ID, headerInfo)
}
if form.Locked != nil {
diff --git a/internal/processing/admin/createdomainblock.go b/internal/processing/admin/createdomainblock.go
index 1c641950c..b42445380 100644
--- a/internal/processing/admin/createdomainblock.go
+++ b/internal/processing/admin/createdomainblock.go
@@ -24,13 +24,14 @@ import (
"strings"
"time"
- "github.com/sirupsen/logrus"
+ "codeberg.org/gruf/go-kv"
"github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/text"
)
@@ -90,10 +91,10 @@ func (p *processor) DomainBlockCreate(ctx context.Context, account *gtsmodel.Acc
// 2. Delete the instance account for that instance if it exists.
// 3. Select all accounts from this instance and pass them through the delete functionality of the processor.
func (p *processor) initiateDomainBlockSideEffects(ctx context.Context, account *gtsmodel.Account, block *gtsmodel.DomainBlock) {
- l := logrus.WithFields(logrus.Fields{
- "func": "domainBlockProcessSideEffects",
- "domain": block.Domain,
- })
+ l := log.WithFields(kv.Fields{
+
+ {"domain", block.Domain},
+ }...)
l.Debug("processing domain block side effects")
diff --git a/internal/processing/admin/importdomainblocks.go b/internal/processing/admin/importdomainblocks.go
index b78589b8a..57235a5b8 100644
--- a/internal/processing/admin/importdomainblocks.go
+++ b/internal/processing/admin/importdomainblocks.go
@@ -34,7 +34,6 @@ import (
// DomainBlocksImport handles the import of a bunch of domain blocks at once, by calling the DomainBlockCreate function for each domain in the provided file.
func (p *processor) DomainBlocksImport(ctx context.Context, account *gtsmodel.Account, domains *multipart.FileHeader) ([]*apimodel.DomainBlock, gtserror.WithCode) {
-
f, err := domains.Open()
if err != nil {
return nil, gtserror.NewErrorBadRequest(fmt.Errorf("DomainBlocksImport: error opening attachment: %s", err))
@@ -56,7 +55,6 @@ func (p *processor) DomainBlocksImport(ctx context.Context, account *gtsmodel.Ac
blocks := []*apimodel.DomainBlock{}
for _, d := range d {
block, err := p.DomainBlockCreate(ctx, account, d.Domain.Domain, false, d.PublicComment, "", "")
-
if err != nil {
return nil, err
}
diff --git a/internal/processing/admin/mediaprune.go b/internal/processing/admin/mediaprune.go
index 1c3398b78..40652c3ca 100644
--- a/internal/processing/admin/mediaprune.go
+++ b/internal/processing/admin/mediaprune.go
@@ -22,8 +22,8 @@ import (
"context"
"fmt"
- "github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
)
func (p *processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gtserror.WithCode {
@@ -35,27 +35,27 @@ func (p *processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gt
go func() {
pruned, err := p.mediaManager.PruneAllRemote(ctx, mediaRemoteCacheDays)
if err != nil {
- logrus.Errorf("MediaPrune: error pruning remote cache: %s", err)
+ log.Errorf("MediaPrune: error pruning remote cache: %s", err)
} else {
- logrus.Infof("MediaPrune: pruned %d remote cache entries", pruned)
+ log.Infof("MediaPrune: pruned %d remote cache entries", pruned)
}
}()
go func() {
pruned, err := p.mediaManager.PruneUnusedLocalAttachments(ctx)
if err != nil {
- logrus.Errorf("MediaPrune: error pruning unused local cache: %s", err)
+ log.Errorf("MediaPrune: error pruning unused local cache: %s", err)
} else {
- logrus.Infof("MediaPrune: pruned %d unused local cache entries", pruned)
+ log.Infof("MediaPrune: pruned %d unused local cache entries", pruned)
}
}()
go func() {
pruned, err := p.mediaManager.PruneAllMeta(ctx)
if err != nil {
- logrus.Errorf("MediaPrune: error pruning meta: %s", err)
+ log.Errorf("MediaPrune: error pruning meta: %s", err)
} else {
- logrus.Infof("MediaPrune: pruned %d meta entries", pruned)
+ log.Infof("MediaPrune: pruned %d meta entries", pruned)
}
}()
diff --git a/internal/processing/fromclientapi.go b/internal/processing/fromclientapi.go
index 24465a059..0f684f200 100644
--- a/internal/processing/fromclientapi.go
+++ b/internal/processing/fromclientapi.go
@@ -24,15 +24,36 @@ import (
"fmt"
"net/url"
+ "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-logger/v2/level"
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages"
)
func (p *processor) ProcessFromClientAPI(ctx context.Context, clientMsg messages.FromClientAPI) error {
+ // Allocate new log fields slice
+ fields := make([]kv.Field, 3, 4)
+ fields[0] = kv.Field{"activityType", clientMsg.APActivityType}
+ fields[1] = kv.Field{"objectType", clientMsg.APObjectType}
+ fields[2] = kv.Field{"fromAccount", clientMsg.OriginAccount.Username}
+
+ if clientMsg.GTSModel != nil &&
+ log.Level() >= level.DEBUG {
+ // Append converted model to log
+ fields = append(fields, kv.Field{
+ "model", clientMsg.GTSModel,
+ })
+ }
+
+ // Log this federated message
+ l := log.WithFields(fields...)
+ l.Info("processing from client")
+
switch clientMsg.APActivityType {
case ap.ActivityCreate:
// CREATE
diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go
index e39a6b4e8..132b33f4c 100644
--- a/internal/processing/fromfederator.go
+++ b/internal/processing/fromfederator.go
@@ -24,11 +24,13 @@ import (
"fmt"
"net/url"
- "github.com/sirupsen/logrus"
+ "codeberg.org/gruf/go-kv"
+ "codeberg.org/gruf/go-logger/v2/level"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/federation/dereferencing"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages"
)
@@ -36,12 +38,30 @@ import (
// and directs the message into the appropriate side effect handler function, or simply does nothing if there's
// no handler function defined for the combination of Activity and Object.
func (p *processor) ProcessFromFederator(ctx context.Context, federatorMsg messages.FromFederator) error {
- l := logrus.WithFields(logrus.Fields{
- "func": "processFromFederator",
- "APActivityType": federatorMsg.APActivityType,
- "APObjectType": federatorMsg.APObjectType,
- })
- l.Trace("processing message from federator")
+ // Allocate new log fields slice
+ fields := make([]kv.Field, 3, 5)
+ fields[0] = kv.Field{"activityType", federatorMsg.APActivityType}
+ fields[1] = kv.Field{"objectType", federatorMsg.APObjectType}
+ fields[2] = kv.Field{"toAccount", federatorMsg.ReceivingAccount.Username}
+
+ if federatorMsg.APIri != nil {
+ // An IRI was supplied, append to log
+ fields = append(fields, kv.Field{
+ "iri", federatorMsg.APIri,
+ })
+ }
+
+ if federatorMsg.GTSModel != nil &&
+ log.Level() >= level.DEBUG {
+ // Append converted model to log
+ fields = append(fields, kv.Field{
+ "model", federatorMsg.GTSModel,
+ })
+ }
+
+ // Log this federated message
+ l := log.WithFields(fields...)
+ l.Info("processing from federator")
switch federatorMsg.APActivityType {
case ap.ActivityCreate:
diff --git a/internal/processing/media/getemoji.go b/internal/processing/media/getemoji.go
index e84e5b570..ee33c25eb 100644
--- a/internal/processing/media/getemoji.go
+++ b/internal/processing/media/getemoji.go
@@ -22,10 +22,10 @@ import (
"context"
"fmt"
- "github.com/sirupsen/logrus"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
)
func (p *processor) GetCustomEmojis(ctx context.Context) ([]*apimodel.Emoji, gtserror.WithCode) {
@@ -40,7 +40,7 @@ func (p *processor) GetCustomEmojis(ctx context.Context) ([]*apimodel.Emoji, gts
for _, gtsEmoji := range emojis {
apiEmoji, err := p.tc.EmojiToAPIEmoji(ctx, gtsEmoji)
if err != nil {
- logrus.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
+ log.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
continue
}
apiEmojis = append(apiEmojis, &apiEmoji)
diff --git a/internal/processing/notification.go b/internal/processing/notification.go
index ee0e4ae34..9b99141a6 100644
--- a/internal/processing/notification.go
+++ b/internal/processing/notification.go
@@ -21,18 +21,15 @@ package processing
import (
"context"
- "github.com/sirupsen/logrus"
-
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/timeline"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
func (p *processor) NotificationsGet(ctx context.Context, authed *oauth.Auth, limit int, maxID string, sinceID string) (*apimodel.TimelineResponse, gtserror.WithCode) {
- l := logrus.WithField("func", "NotificationsGet")
-
notifs, err := p.db.GetNotifications(ctx, authed.Account.ID, limit, maxID, sinceID)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
@@ -46,7 +43,7 @@ func (p *processor) NotificationsGet(ctx context.Context, authed *oauth.Auth, li
for _, n := range notifs {
apiNotif, err := p.tc.NotificationToAPINotification(ctx, n)
if err != nil {
- l.Debugf("got an error converting a notification to api, will skip it: %s", err)
+ log.Debugf("got an error converting a notification to api, will skip it: %s", err)
continue
}
timelineables = append(timelineables, apiNotif)
diff --git a/internal/processing/search.go b/internal/processing/search.go
index ee64526e5..d25bee2ae 100644
--- a/internal/processing/search.go
+++ b/internal/processing/search.go
@@ -25,22 +25,23 @@ import (
"net/url"
"strings"
- "github.com/sirupsen/logrus"
+ "codeberg.org/gruf/go-kv"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation/dereferencing"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
func (p *processor) SearchGet(ctx context.Context, authed *oauth.Auth, search *apimodel.SearchQuery) (*apimodel.SearchResult, gtserror.WithCode) {
- l := logrus.WithFields(logrus.Fields{
- "func": "SearchGet",
- "query": search.Query,
- })
+ l := log.WithFields(kv.Fields{
+
+ {"query", search.Query},
+ }...)
// tidy up the query and make sure it wasn't just spaces
query := strings.TrimSpace(search.Query)
@@ -133,11 +134,11 @@ func (p *processor) SearchGet(ctx context.Context, authed *oauth.Auth, search *a
}
func (p *processor) searchStatusByURI(ctx context.Context, authed *oauth.Auth, uri *url.URL, resolve bool) (*gtsmodel.Status, error) {
- l := logrus.WithFields(logrus.Fields{
- "func": "searchStatusByURI",
- "uri": uri.String(),
- "resolve": resolve,
- })
+ l := log.WithFields(kv.Fields{
+
+ {"uri", uri.String()},
+ {"resolve", resolve},
+ }...)
if maybeStatus, err := p.db.GetStatusByURI(ctx, uri.String()); err == nil {
return maybeStatus, nil
diff --git a/internal/processing/status/util.go b/internal/processing/status/util.go
index 79c416f98..52214e95f 100644
--- a/internal/processing/status/util.go
+++ b/internal/processing/status/util.go
@@ -23,11 +23,11 @@ import (
"errors"
"fmt"
- "github.com/sirupsen/logrus"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@@ -204,12 +204,12 @@ func (p *processor) ProcessMentions(ctx context.Context, form *apimodel.Advanced
for _, mentionedAccountName := range mentionedAccountNames {
gtsMention, err := p.parseMention(ctx, mentionedAccountName, accountID, status.ID)
if err != nil {
- logrus.Errorf("ProcessMentions: error parsing mention %s from status: %s", mentionedAccountName, err)
+ log.Errorf("ProcessMentions: error parsing mention %s from status: %s", mentionedAccountName, err)
continue
}
if err := p.db.Put(ctx, gtsMention); err != nil {
- logrus.Errorf("ProcessMentions: error putting mention in db: %s", err)
+ log.Errorf("ProcessMentions: error putting mention in db: %s", err)
}
mentions = append(mentions, gtsMention)
diff --git a/internal/processing/status/util_test.go b/internal/processing/status/util_test.go
index 80c2da897..f1b826bd0 100644
--- a/internal/processing/status/util_test.go
+++ b/internal/processing/status/util_test.go
@@ -34,8 +34,11 @@ const statusText1 = `Another test @foss_satan@fossbros-anonymous.io
#Hashtag
Text`
-const statusText1ExpectedFull = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br><br><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>Hashtag</span></a><br><br>Text</p>"
-const statusText1ExpectedPartial = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br><br>#Hashtag<br><br>Text</p>"
+
+const (
+ statusText1ExpectedFull = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br><br><a href=\"http://localhost:8080/tags/Hashtag\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\">#<span>Hashtag</span></a><br><br>Text</p>"
+ statusText1ExpectedPartial = "<p>Another test <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span><br><br>#Hashtag<br><br>Text</p>"
+)
const statusText2 = `Another test @foss_satan@fossbros-anonymous.io
@@ -97,7 +100,6 @@ func (suite *UtilTestSuite) TestProcessMentions1() {
}
func (suite *UtilTestSuite) TestProcessContentFull1() {
-
/*
TEST PREPARATION
*/
@@ -146,7 +148,6 @@ func (suite *UtilTestSuite) TestProcessContentFull1() {
}
func (suite *UtilTestSuite) TestProcessContentPartial1() {
-
/*
TEST PREPARATION
*/
@@ -238,7 +239,6 @@ func (suite *UtilTestSuite) TestProcessMentions2() {
}
func (suite *UtilTestSuite) TestProcessContentFull2() {
-
/*
TEST PREPARATION
*/
@@ -288,7 +288,6 @@ func (suite *UtilTestSuite) TestProcessContentFull2() {
}
func (suite *UtilTestSuite) TestProcessContentPartial2() {
-
/*
TEST PREPARATION
*/
diff --git a/internal/processing/statustimeline.go b/internal/processing/statustimeline.go
index 081709302..b7313818c 100644
--- a/internal/processing/statustimeline.go
+++ b/internal/processing/statustimeline.go
@@ -23,12 +23,11 @@ import (
"errors"
"fmt"
- "github.com/sirupsen/logrus"
-
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/timeline"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
@@ -73,7 +72,7 @@ func StatusFilterFunction(database db.DB, filter visibility.Filter) timeline.Fil
timelineable, err := filter.StatusHometimelineable(ctx, status, requestingAccount)
if err != nil {
- logrus.Warnf("error checking hometimelineability of status %s for account %s: %s", status.ID, timelineAccountID, err)
+ log.Warnf("error checking hometimelineability of status %s for account %s: %s", status.ID, timelineAccountID, err)
}
return timelineable, nil // we don't return the error here because we want to just skip this item if something goes wrong
@@ -235,14 +234,12 @@ func (p *processor) FavedTimelineGet(ctx context.Context, authed *oauth.Auth, ma
}
func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth, statuses []*gtsmodel.Status) ([]*apimodel.Status, error) {
- l := logrus.WithField("func", "filterPublicStatuses")
-
apiStatuses := []*apimodel.Status{}
for _, s := range statuses {
targetAccount := &gtsmodel.Account{}
if err := p.db.GetByID(ctx, s.AccountID, targetAccount); err != nil {
if err == db.ErrNoEntries {
- l.Debugf("filterPublicStatuses: skipping status %s because account %s can't be found in the db", s.ID, s.AccountID)
+ log.Debugf("filterPublicStatuses: skipping status %s because account %s can't be found in the db", s.ID, s.AccountID)
continue
}
return nil, gtserror.NewErrorInternalError(fmt.Errorf("filterPublicStatuses: error getting status author: %s", err))
@@ -250,7 +247,7 @@ func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth
timelineable, err := p.filter.StatusPublictimelineable(ctx, s, authed.Account)
if err != nil {
- l.Debugf("filterPublicStatuses: skipping status %s because of an error checking status visibility: %s", s.ID, err)
+ log.Debugf("filterPublicStatuses: skipping status %s because of an error checking status visibility: %s", s.ID, err)
continue
}
if !timelineable {
@@ -259,7 +256,7 @@ func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth
apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, authed.Account)
if err != nil {
- l.Debugf("filterPublicStatuses: skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err)
+ log.Debugf("filterPublicStatuses: skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err)
continue
}
@@ -270,14 +267,12 @@ func (p *processor) filterPublicStatuses(ctx context.Context, authed *oauth.Auth
}
func (p *processor) filterFavedStatuses(ctx context.Context, authed *oauth.Auth, statuses []*gtsmodel.Status) ([]*apimodel.Status, error) {
- l := logrus.WithField("func", "filterFavedStatuses")
-
apiStatuses := []*apimodel.Status{}
for _, s := range statuses {
targetAccount := &gtsmodel.Account{}
if err := p.db.GetByID(ctx, s.AccountID, targetAccount); err != nil {
if err == db.ErrNoEntries {
- l.Debugf("filterFavedStatuses: skipping status %s because account %s can't be found in the db", s.ID, s.AccountID)
+ log.Debugf("filterFavedStatuses: skipping status %s because account %s can't be found in the db", s.ID, s.AccountID)
continue
}
return nil, gtserror.NewErrorInternalError(fmt.Errorf("filterPublicStatuses: error getting status author: %s", err))
@@ -285,7 +280,7 @@ func (p *processor) filterFavedStatuses(ctx context.Context, authed *oauth.Auth,
timelineable, err := p.filter.StatusVisible(ctx, s, authed.Account)
if err != nil {
- l.Debugf("filterFavedStatuses: skipping status %s because of an error checking status visibility: %s", s.ID, err)
+ log.Debugf("filterFavedStatuses: skipping status %s because of an error checking status visibility: %s", s.ID, err)
continue
}
if !timelineable {
@@ -294,7 +289,7 @@ func (p *processor) filterFavedStatuses(ctx context.Context, authed *oauth.Auth,
apiStatus, err := p.tc.StatusToAPIStatus(ctx, s, authed.Account)
if err != nil {
- l.Debugf("filterFavedStatuses: skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err)
+ log.Debugf("filterFavedStatuses: skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err)
continue
}
diff --git a/internal/processing/streaming/openstream.go b/internal/processing/streaming/openstream.go
index b005ef9bd..3623a7ceb 100644
--- a/internal/processing/streaming/openstream.go
+++ b/internal/processing/streaming/openstream.go
@@ -23,19 +23,20 @@ import (
"errors"
"fmt"
- "github.com/sirupsen/logrus"
+ "codeberg.org/gruf/go-kv"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/stream"
)
func (p *processor) OpenStreamForAccount(ctx context.Context, account *gtsmodel.Account, streamTimeline string) (*stream.Stream, gtserror.WithCode) {
- l := logrus.WithFields(logrus.Fields{
- "func": "OpenStreamForAccount",
- "account": account.ID,
- "streamType": streamTimeline,
- })
+ l := log.WithFields(kv.Fields{
+
+ {"account", account.ID},
+ {"streamType", streamTimeline},
+ }...)
l.Debug("received open stream request")
// each stream needs a unique ID so we know to close it