From 29547ce8aba63454e84d277b0597fb2764e8cb23 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 3 Nov 2025 21:16:42 +0100 Subject: [bugfix] more RSS validation issues (#4517) Fixes some validation issues relating to author information often expected to be valid email addresses, which our @displayname@username is not. There's still a few more validation issues, but honestly if we're going have better support I think it might be worth dropping gorilla/feeds for our own tagged XML / JSON structs. Also does a bunch of housekeeping in the typeutils package removing error returns where never used / only ever logged, removing unused contexts etc. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4517 Co-authored-by: kim Co-committed-by: kim --- internal/processing/media/create.go | 10 +++------- internal/processing/media/getfile.go | 2 +- internal/processing/media/getmedia.go | 7 ++----- internal/processing/media/unattach.go | 7 ++----- internal/processing/media/update.go | 7 ++----- 5 files changed, 10 insertions(+), 23 deletions(-) (limited to 'internal/processing/media') diff --git a/internal/processing/media/create.go b/internal/processing/media/create.go index e925297ff..aaccf4bde 100644 --- a/internal/processing/media/create.go +++ b/internal/processing/media/create.go @@ -29,6 +29,7 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" "code.superseriousbusiness.org/gotosocial/internal/media" + "code.superseriousbusiness.org/gotosocial/internal/typeutils" "codeberg.org/gruf/go-iotools" ) @@ -89,11 +90,6 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form return nil, errWithCode } - apiAttachment, err := p.converter.AttachmentToAPIAttachment(ctx, attachment) - if err != nil { - err := fmt.Errorf("error parsing media attachment to frontend type: %s", err) - return nil, gtserror.NewErrorInternalError(err) - } - - return &apiAttachment, nil + a := typeutils.AttachmentToAPIAttachment(attachment) + return &a, nil } diff --git a/internal/processing/media/getfile.go b/internal/processing/media/getfile.go index 79ab08291..3b9b92adc 100644 --- a/internal/processing/media/getfile.go +++ b/internal/processing/media/getfile.go @@ -247,7 +247,7 @@ func (p *Processor) getEmojiContent( emoji, err = p.federator.RecacheEmoji( ctx, emoji, - false, + false, // async ) if err != nil { err := gtserror.Newf("error recaching emoji: %w", err) diff --git a/internal/processing/media/getmedia.go b/internal/processing/media/getmedia.go index 5144bbd8e..22e05cab3 100644 --- a/internal/processing/media/getmedia.go +++ b/internal/processing/media/getmedia.go @@ -26,6 +26,7 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/db" "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" + "code.superseriousbusiness.org/gotosocial/internal/typeutils" ) func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, mediaAttachmentID string) (*apimodel.Attachment, gtserror.WithCode) { @@ -42,10 +43,6 @@ func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, mediaAtt return nil, gtserror.NewErrorNotFound(errors.New("attachment not owned by requesting account")) } - a, err := p.converter.AttachmentToAPIAttachment(ctx, attachment) - if err != nil { - return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err)) - } - + a := typeutils.AttachmentToAPIAttachment(attachment) return &a, nil } diff --git a/internal/processing/media/unattach.go b/internal/processing/media/unattach.go index 8eec907fd..55d793647 100644 --- a/internal/processing/media/unattach.go +++ b/internal/processing/media/unattach.go @@ -26,6 +26,7 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/db" "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" + "code.superseriousbusiness.org/gotosocial/internal/typeutils" ) // Unattach unattaches the media attachment with the given ID from any statuses it was attached to, making it available @@ -49,10 +50,6 @@ func (p *Processor) Unattach(ctx context.Context, account *gtsmodel.Account, med return nil, gtserror.NewErrorNotFound(fmt.Errorf("db error updating attachment: %s", err)) } - a, err := p.converter.AttachmentToAPIAttachment(ctx, attachment) - if err != nil { - return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err)) - } - + a := typeutils.AttachmentToAPIAttachment(attachment) return &a, nil } diff --git a/internal/processing/media/update.go b/internal/processing/media/update.go index 3acf238b0..cccc27534 100644 --- a/internal/processing/media/update.go +++ b/internal/processing/media/update.go @@ -29,6 +29,7 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" "code.superseriousbusiness.org/gotosocial/internal/text" + "code.superseriousbusiness.org/gotosocial/internal/typeutils" ) // Update updates a media attachment with the given id, using the provided form parameters. @@ -77,11 +78,7 @@ func (p *Processor) Update(ctx context.Context, account *gtsmodel.Account, media return nil, gtserror.NewErrorInternalError(fmt.Errorf("database error updating media: %s", err)) } - a, err := p.converter.AttachmentToAPIAttachment(ctx, attachment) - if err != nil { - return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err)) - } - + a := typeutils.AttachmentToAPIAttachment(attachment) return &a, nil } -- cgit v1.2.3