mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 03:03:16 -06:00
always directly use global logrus logger instead of referencing an instance
This commit is contained in:
parent
1f7049a7c3
commit
7018ec27cd
2 changed files with 19 additions and 25 deletions
|
|
@ -292,8 +292,6 @@ func (d *deref) populateStatusFields(ctx context.Context, status *gtsmodel.Statu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Status, requestingUsername string) error {
|
func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Status, requestingUsername string) error {
|
||||||
l := logrus.StandardLogger()
|
|
||||||
|
|
||||||
// At this point, mentions should have the namestring and mentionedAccountURI set on them.
|
// At this point, mentions should have the namestring and mentionedAccountURI set on them.
|
||||||
// We can use these to find the accounts.
|
// We can use these to find the accounts.
|
||||||
|
|
||||||
|
|
@ -302,20 +300,20 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta
|
||||||
for _, m := range status.Mentions {
|
for _, m := range status.Mentions {
|
||||||
if m.ID != "" {
|
if m.ID != "" {
|
||||||
// we've already populated this mention, since it has an ID
|
// we've already populated this mention, since it has an ID
|
||||||
l.Debug("populateStatusMentions: mention already populated")
|
logrus.Debug("populateStatusMentions: mention already populated")
|
||||||
mentionIDs = append(mentionIDs, m.ID)
|
mentionIDs = append(mentionIDs, m.ID)
|
||||||
newMentions = append(newMentions, m)
|
newMentions = append(newMentions, m)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.TargetAccountURI == "" {
|
if m.TargetAccountURI == "" {
|
||||||
l.Debug("populateStatusMentions: target URI not set on mention")
|
logrus.Debug("populateStatusMentions: target URI not set on mention")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
targetAccountURI, err := url.Parse(m.TargetAccountURI)
|
targetAccountURI, err := url.Parse(m.TargetAccountURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Debugf("populateStatusMentions: error parsing mentioned account uri %s: %s", m.TargetAccountURI, err)
|
logrus.Debugf("populateStatusMentions: error parsing mentioned account uri %s: %s", m.TargetAccountURI, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +324,7 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta
|
||||||
if a, err := d.db.GetAccountByURI(ctx, targetAccountURI.String()); err != nil {
|
if a, err := d.db.GetAccountByURI(ctx, targetAccountURI.String()); err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err.Error())
|
||||||
} else {
|
} else {
|
||||||
l.Debugf("populateStatusMentions: got target account %s with id %s through GetAccountByURI", targetAccountURI, a.ID)
|
logrus.Debugf("populateStatusMentions: got target account %s with id %s through GetAccountByURI", targetAccountURI, a.ID)
|
||||||
targetAccount = a
|
targetAccount = a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,13 +334,13 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta
|
||||||
if a, _, err := d.GetRemoteAccount(ctx, requestingUsername, targetAccountURI, false); err != nil {
|
if a, _, err := d.GetRemoteAccount(ctx, requestingUsername, targetAccountURI, false); err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err.Error())
|
||||||
} else {
|
} else {
|
||||||
l.Debugf("populateStatusMentions: got target account %s with id %s through GetRemoteAccount", targetAccountURI, a.ID)
|
logrus.Debugf("populateStatusMentions: got target account %s with id %s through GetRemoteAccount", targetAccountURI, a.ID)
|
||||||
targetAccount = a
|
targetAccount = a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetAccount == nil {
|
if targetAccount == nil {
|
||||||
l.Debugf("populateStatusMentions: couldn't get target account %s: %s", m.TargetAccountURI, strings.Join(errs, " : "))
|
logrus.Debugf("populateStatusMentions: couldn't get target account %s: %s", m.TargetAccountURI, strings.Join(errs, " : "))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,8 +380,6 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deref) populateStatusAttachments(ctx context.Context, status *gtsmodel.Status, requestingUsername string) error {
|
func (d *deref) populateStatusAttachments(ctx context.Context, status *gtsmodel.Status, requestingUsername string) error {
|
||||||
l := logrus.StandardLogger()
|
|
||||||
|
|
||||||
// At this point we should know:
|
// At this point we should know:
|
||||||
// * the media type of the file we're looking for (a.File.ContentType)
|
// * the media type of the file we're looking for (a.File.ContentType)
|
||||||
// * the file type (a.Type)
|
// * the file type (a.Type)
|
||||||
|
|
@ -399,7 +395,7 @@ func (d *deref) populateStatusAttachments(ctx context.Context, status *gtsmodel.
|
||||||
|
|
||||||
attachment, err := d.GetRemoteAttachment(ctx, requestingUsername, a)
|
attachment, err := d.GetRemoteAttachment(ctx, requestingUsername, a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("populateStatusAttachments: couldn't get remote attachment %s: %s", a.RemoteURL, err)
|
logrus.Errorf("populateStatusAttachments: couldn't get remote attachment %s: %s", a.RemoteURL, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -303,8 +303,6 @@ func (c *converter) TagToAPITag(ctx context.Context, t *gtsmodel.Tag) (model.Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*model.Status, error) {
|
func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*model.Status, error) {
|
||||||
l := logrus.StandardLogger()
|
|
||||||
|
|
||||||
repliesCount, err := c.db.CountStatusReplies(ctx, s)
|
repliesCount, err := c.db.CountStatusReplies(ctx, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error counting replies: %s", err)
|
return nil, fmt.Errorf("error counting replies: %s", err)
|
||||||
|
|
@ -381,7 +379,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, gtsAttachment := range s.Attachments {
|
for _, gtsAttachment := range s.Attachments {
|
||||||
apiAttachment, err := c.AttachmentToAPIAttachment(ctx, gtsAttachment)
|
apiAttachment, err := c.AttachmentToAPIAttachment(ctx, gtsAttachment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting attachment with id %s: %s", gtsAttachment.ID, err)
|
logrus.Errorf("error converting attachment with id %s: %s", gtsAttachment.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiAttachments = append(apiAttachments, apiAttachment)
|
apiAttachments = append(apiAttachments, apiAttachment)
|
||||||
|
|
@ -392,12 +390,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, aID := range s.AttachmentIDs {
|
for _, aID := range s.AttachmentIDs {
|
||||||
gtsAttachment, err := c.db.GetAttachmentByID(ctx, aID)
|
gtsAttachment, err := c.db.GetAttachmentByID(ctx, aID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error getting attachment with id %s: %s", aID, err)
|
logrus.Errorf("error getting attachment with id %s: %s", aID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiAttachment, err := c.AttachmentToAPIAttachment(ctx, gtsAttachment)
|
apiAttachment, err := c.AttachmentToAPIAttachment(ctx, gtsAttachment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting attachment with id %s: %s", aID, err)
|
logrus.Errorf("error converting attachment with id %s: %s", aID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiAttachments = append(apiAttachments, apiAttachment)
|
apiAttachments = append(apiAttachments, apiAttachment)
|
||||||
|
|
@ -411,7 +409,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, gtsMention := range s.Mentions {
|
for _, gtsMention := range s.Mentions {
|
||||||
apiMention, err := c.MentionToAPIMention(ctx, gtsMention)
|
apiMention, err := c.MentionToAPIMention(ctx, gtsMention)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting mention with id %s: %s", gtsMention.ID, err)
|
logrus.Errorf("error converting mention with id %s: %s", gtsMention.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiMentions = append(apiMentions, apiMention)
|
apiMentions = append(apiMentions, apiMention)
|
||||||
|
|
@ -422,12 +420,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, mID := range s.MentionIDs {
|
for _, mID := range s.MentionIDs {
|
||||||
gtsMention, err := c.db.GetMention(ctx, mID)
|
gtsMention, err := c.db.GetMention(ctx, mID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error getting mention with id %s: %s", mID, err)
|
logrus.Errorf("error getting mention with id %s: %s", mID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiMention, err := c.MentionToAPIMention(ctx, gtsMention)
|
apiMention, err := c.MentionToAPIMention(ctx, gtsMention)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting mention with id %s: %s", gtsMention.ID, err)
|
logrus.Errorf("error converting mention with id %s: %s", gtsMention.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiMentions = append(apiMentions, apiMention)
|
apiMentions = append(apiMentions, apiMention)
|
||||||
|
|
@ -441,7 +439,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, gtsTag := range s.Tags {
|
for _, gtsTag := range s.Tags {
|
||||||
apiTag, err := c.TagToAPITag(ctx, gtsTag)
|
apiTag, err := c.TagToAPITag(ctx, gtsTag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting tag with id %s: %s", gtsTag.ID, err)
|
logrus.Errorf("error converting tag with id %s: %s", gtsTag.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiTags = append(apiTags, apiTag)
|
apiTags = append(apiTags, apiTag)
|
||||||
|
|
@ -452,12 +450,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, t := range s.TagIDs {
|
for _, t := range s.TagIDs {
|
||||||
gtsTag := >smodel.Tag{}
|
gtsTag := >smodel.Tag{}
|
||||||
if err := c.db.GetByID(ctx, t, gtsTag); err != nil {
|
if err := c.db.GetByID(ctx, t, gtsTag); err != nil {
|
||||||
l.Errorf("error getting tag with id %s: %s", t, err)
|
logrus.Errorf("error getting tag with id %s: %s", t, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiTag, err := c.TagToAPITag(ctx, gtsTag)
|
apiTag, err := c.TagToAPITag(ctx, gtsTag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting tag with id %s: %s", gtsTag.ID, err)
|
logrus.Errorf("error converting tag with id %s: %s", gtsTag.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiTags = append(apiTags, apiTag)
|
apiTags = append(apiTags, apiTag)
|
||||||
|
|
@ -471,7 +469,7 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, gtsEmoji := range s.Emojis {
|
for _, gtsEmoji := range s.Emojis {
|
||||||
apiEmoji, err := c.EmojiToAPIEmoji(ctx, gtsEmoji)
|
apiEmoji, err := c.EmojiToAPIEmoji(ctx, gtsEmoji)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
|
logrus.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiEmojis = append(apiEmojis, apiEmoji)
|
apiEmojis = append(apiEmojis, apiEmoji)
|
||||||
|
|
@ -482,12 +480,12 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
|
||||||
for _, e := range s.EmojiIDs {
|
for _, e := range s.EmojiIDs {
|
||||||
gtsEmoji := >smodel.Emoji{}
|
gtsEmoji := >smodel.Emoji{}
|
||||||
if err := c.db.GetByID(ctx, e, gtsEmoji); err != nil {
|
if err := c.db.GetByID(ctx, e, gtsEmoji); err != nil {
|
||||||
l.Errorf("error getting emoji with id %s: %s", e, err)
|
logrus.Errorf("error getting emoji with id %s: %s", e, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiEmoji, err := c.EmojiToAPIEmoji(ctx, gtsEmoji)
|
apiEmoji, err := c.EmojiToAPIEmoji(ctx, gtsEmoji)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
|
logrus.Errorf("error converting emoji with id %s: %s", gtsEmoji.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
apiEmojis = append(apiEmojis, apiEmoji)
|
apiEmojis = append(apiEmojis, apiEmoji)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue